Skip to content

Commit

Permalink
Merge pull request #252 from codepress/release/3.4.7
Browse files Browse the repository at this point in the history
Release/3.4.7
  • Loading branch information
DGStefan authored Aug 26, 2019
2 parents 2be6684 + a2f9ad5 commit 40d4cf0
Show file tree
Hide file tree
Showing 16 changed files with 270 additions and 382 deletions.
2 changes: 1 addition & 1 deletion assets/css/ac-jquery-ui.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/css/table.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/admin-page-columns.js.map

Large diffs are not rendered by default.

326 changes: 1 addition & 325 deletions assets/js/select2.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/table.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion classes/Column/Taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public function get_value( $post_id ) {
return $this->get_empty_char();
}

return ac_helper()->string->enumeration_list( $terms, 'and' );
$setting_limit = $this->get_setting( 'number_of_items' );

return ac_helper()->html->more( $terms, $setting_limit ? $setting_limit->get_value() : false );
}

/**
Expand All @@ -48,6 +50,7 @@ public function get_raw_value( $post_id ) {

public function register_settings() {
$this->add_setting( new Settings\Column\Taxonomy( $this ) );
$this->add_setting( new Settings\Column\NumberOfItems( $this ) );
}

}
24 changes: 11 additions & 13 deletions classes/Helper/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class Html {
* @param string $key
* @param string $value
*
* @since 3.0
* @return string
* @since 3.0
*/
public function get_attribute_as_string( $key, $value ) {
return sprintf( '%s="%s"', $key, esc_attr( trim( $value ) ) );
Expand All @@ -20,8 +20,8 @@ public function get_attribute_as_string( $key, $value ) {
/**
* @param array $attributes
*
* @since 3.0
* @return string
* @since 3.0
*/
public function get_attributes_as_string( array $attributes ) {
$output = array();
Expand Down Expand Up @@ -390,24 +390,22 @@ public function progress_bar( $args = array() ) {
}

public function more( $array, $number = 10, $glue = ', ' ) {
if ( ! $number ) {
return implode( $glue, $array );
}

$first_set = array_slice( $array, 0, $number );
$last_set = array_slice( $array, $number );

ob_start();

if ( $first_set ) {
$first = sprintf( '<span class="ac-show-more__part -first">%s</span>', implode( $glue, $first_set ) );
$more = $last_set ? sprintf( '<span class="ac-show-more__part -more">%s%s</span>', $glue, implode( $glue, $last_set ) ) : '';
$content = sprintf('<span class="ac-show-more__content">%s%s</span>', $first, $more );
$toggler = $last_set ? sprintf( '<span class="ac-show-more__divider">|</span><a class="ac-show-more__toggle" data-show-more-toggle data-more="%1$s" data-less="%2$s">%1$s</a>', sprintf( __( '%s more', 'codepress-admin-columns' ), count( $last_set ) ), strtolower( __( 'Hide', 'codepress-admin-columns' ) ) ) : '';

echo implode( $glue, $first_set );

if ( $last_set ) { ?>
<span class="ac-more-link-show">( <a><?php printf( __( 'Show %s more', 'codepress-admin-columns' ), count( $last_set ) ); ?></a> )</span>
<span class="ac-show-more-block">
<?php echo $glue . implode( $glue, $first_set ); ?>
<br/>
<span class="ac-more-link-hide">( <a><?php _e( 'Hide', 'codepress-admin-columns' ); ?></a> )</span>
</span>
<?php
}
echo sprintf( '<span class="ac-show-more">%s</span>', $content . $toggler );
}

return ob_get_clean();
Expand Down
2 changes: 1 addition & 1 deletion classes/Settings/Column/DateTimeFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ protected function get_date_options() {
$custom_label = $this->get_html_label(
__( 'Custom:', 'codepress-admin-columns' ),
'',
sprintf( __( 'Learn more about %s.', 'codepress-admin-columns' ), ac_helper()->html->link( 'http://codex.wordpress.org/Formatting_Date_and_Time', __( 'date and time formatting', 'codepress-admin-columns' ) ), array( 'target' => '_blank' ) )
sprintf( __( 'Learn more about %s.', 'codepress-admin-columns' ), ac_helper()->html->link( 'https://wordpress.org/support/article/formatting-date-and-time/', __( 'date and time formatting', 'codepress-admin-columns' ), array( 'target' => '_blank' ) ) )
);

$custom_label .= '<input type="text" class="ac-setting-input-date__custom" value="' . esc_attr( $this->get_date_format() ) . '" disabled>';
Expand Down
4 changes: 2 additions & 2 deletions codepress-admin-columns.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: Admin Columns
Version: 3.4.6
Version: 3.4.7
Description: Customize columns on the administration screens for post(types), pages, media, comments, links and users with an easy to use drag-and-drop interface.
Author: AdminColumns.com
Author URI: https://www.admincolumns.com
Expand Down Expand Up @@ -36,7 +36,7 @@
}

define( 'AC_FILE', __FILE__ );
define( 'AC_VERSION', '3.4.6' );
define( 'AC_VERSION', '3.4.7' );

require_once __DIR__ . '/classes/Dependencies.php';

Expand Down
6 changes: 3 additions & 3 deletions languages/codepress-admin-columns.pot
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ msgstr ""
msgid "Taxonomy"
msgstr ""

#: classes/Helper/Html.php:403
msgid "Show %s more"
#: classes/Helper/Html.php:406
msgid "%s more"
msgstr ""

#: classes/Helper/Html.php:407
#: classes/Helper/Html.php:406
msgid "Hide"
msgstr ""

Expand Down
10 changes: 9 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: plugins, wordpress, admin, column, columns, custom columns, custom fields,
Requires at least: 4.5
Tested up to: 5.2.2
Requires PHP: 5.3.6
Stable tag: 3.4.6
Stable tag: 3.4.7

Customise columns on the administration screens for post(types), pages, media, comments, links and users with an easy to use drag-and-drop interface.

Expand Down Expand Up @@ -213,6 +213,14 @@ You can find a list of the available actions and filters (and examples on how to

== Changelog ==

= 3.4.7 =
Release Date: August 26th, 2019

* [Added] Option to limit the amount of taxonomies that is shown in the column with show more button.
* [Improved] Changed WordPress Date Format link
* [Improved] Show more feature that is used in several columns
* [Improved] Update Select2 version that fixes multiple selections bug

= 3.4.6 =
Release Date: August 21st, 2019

Expand Down
51 changes: 51 additions & 0 deletions src/js/modules/show-more.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
export default class ShowMore {

constructor( el ) {
this.el = el;

this.initEvents();
}

initEvents() {
if ( this.isInited() ) {
return;
}

if( this.getToggler() ){
this.getToggler().addEventListener( 'click', event => {
event.preventDefault();
event.stopPropagation();
this.toggle();
} );
}

this.el.dataset.showMoreInit = true;
}

getToggler() {
return this.el.querySelector( '.ac-show-more__toggle' );
}

isInited() {
return this.el.dataset.showMoreInit;
}

toggle() {
if ( this.el.classList.contains( '-on' ) ) {
this.hide();
} else {
this.show();
}
}

show() {
this.el.classList.add( '-on' );
this.getToggler().innerHTML = this.getToggler().dataset.less;
}

hide() {
this.el.classList.remove( '-on' );
this.getToggler().innerHTML = this.getToggler().dataset.more;
}

}
25 changes: 9 additions & 16 deletions src/js/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import Table from "./table/table";
import Tooltip from "./table/tooltips";
import Modals from "./modules/modals";
import ScreenOptionsColumns from "./table/screen-options-columns";
import ShowMore from "./modules/show-more";

// Register the global variable
global.AdminColumns = typeof AdminColumns !== "undefined" ? AdminColumns : {};

Modals.init();


jQuery( document ).ready( function( $ ) {
ac_quickedit_events( $ );
ac_actions_column( $, $( '.column-actions' ) );
Expand All @@ -33,6 +33,10 @@ jQuery( document ).ready( function( $ ) {
ac_show_more( $ );
} );

$( '.wp-list-table td' ).on( 'ACP_InlineEditing_After_SetValue', function() {
ac_show_more( $ );
} );

} );

global.ac_load_table = function( el ) {
Expand Down Expand Up @@ -119,22 +123,11 @@ function ac_toggle_box_ajax_init( $ ) {
$( 'a[data-ajax-populate=1]' ).bind( 'click', do_retrieve_ajax_value );
}

function ac_show_more( $ ) {
$( '.ac-more-link-show' ).click( function( e ) {
e.preventDefault();
let td = $( this ).hide().closest( 'td' );

td.find( '.ac-show-more-block' ).show();

} );
$( '.ac-more-link-hide' ).click( function( e ) {
e.preventDefault();
let td = $( this ).closest( 'td' );

td.find( '.ac-more-link-show' ).show();
td.find( '.ac-show-more-block' ).hide();
global.ac_show_more = function( $ ) {
document.querySelectorAll( '.ac-show-more' ).forEach( el => {
new ShowMore( el );
} );
}
};

function ac_actions_column( $, $selector ) {
$( $selector ).each( function() {
Expand Down
Loading

0 comments on commit 40d4cf0

Please sign in to comment.