|
8 | 8 | define( 'UNFC_DB_CHECK_ITEM_BATCH_LIMIT', 4096 ); // Database batch size - number of database requests to do in one go when scanning. |
9 | 9 | define( 'UNFC_DB_CHECK_NORMALIZE_BATCH_LIMIT', 4096 ); // Database batch size - number of database requests to do in one go when normalizing. |
10 | 10 | define( 'UNFC_DB_CHECK_LIST_LIMIT', 1000 ); // Initial default number of items to display in listing. |
11 | | -define( 'UNFC_DB_CHECK_TITLE_MAX_LEN', 100 ); // Truncate titles if greater than this length (in UTF-8 chars). |
| 11 | +define( 'UNFC_DB_CHECK_TITLE_MAX_LEN', 100 ); // Truncate displaying of titles if greater than this length (in UTF-8 chars). |
12 | 12 | define( 'UNFC_DB_CHECK_ITEMS_LIST_SEL', '#unfc_db_check_items_list' ); // Selector for items listing. |
13 | 13 | define( 'UNFC_DB_CHECK_SLUGS_LIST_SEL', '#unfc_db_check_slugs_list' ); // Selector for percent-encoded slugs listing. |
14 | 14 |
|
|
23 | 23 | class UNFC_Normalize { |
24 | 24 |
|
25 | 25 | // Handy in themselves and to have for testing (can switch on/off). Set in __construct(). |
26 | | - static $dirname = null; // dirname( __FILE__ ). |
27 | | - static $plugin_basename = null; // plugin_basename( __FILE__ ). |
| 26 | + static $dirname = null; // dirname( UNFC_FILE ). |
| 27 | + static $plugin_basename = null; // plugin_basename( UNFC_FILE ). |
28 | 28 | static $doing_ajax = null; // defined( 'DOING_AJAX' ) && DOING_AJAX. |
29 | 29 | static $have_set_group_concat_max_len = false; // Whether have set the MySQL group_concat_max_len variable for the session. |
30 | 30 |
|
@@ -185,10 +185,10 @@ class UNFC_Normalize { |
185 | 185 | function __construct() { |
186 | 186 |
|
187 | 187 | if ( null === self::$dirname ) { |
188 | | - self::$dirname = dirname( __FILE__ ); |
| 188 | + self::$dirname = dirname( UNFC_FILE ); |
189 | 189 | } |
190 | 190 | if ( null === self::$plugin_basename ) { |
191 | | - self::$plugin_basename = plugin_basename( __FILE__ ); |
| 191 | + self::$plugin_basename = plugin_basename( UNFC_FILE ); |
192 | 192 | } |
193 | 193 | if ( null === self::$doing_ajax ) { |
194 | 194 | self::$doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
@@ -235,14 +235,7 @@ function is_blog_utf8() { |
235 | 235 | * Called on 'admin_init' action. |
236 | 236 | */ |
237 | 237 | function admin_init() { |
238 | | - if ( $this->check_version() && $this->is_blog_utf8() ) { |
239 | | - if ( self::$doing_ajax ) { |
240 | | - add_action( 'wp_ajax_unfc_db_check_list_bulk', array( $this, 'wp_ajax_unfc_db_check_list_bulk' ) ); |
241 | | - add_action( 'wp_ajax_unfc_db_check_list_page', array( $this, 'wp_ajax_unfc_db_check_list_page' ) ); |
242 | | - add_action( 'wp_ajax_unfc_db_check_list_sort', array( $this, 'wp_ajax_unfc_db_check_list_sort' ) ); |
243 | | - add_action( 'wp_ajax_unfc_db_check_list_screen_options', array( $this, 'wp_ajax_unfc_db_check_list_screen_options' ) ); |
244 | | - } |
245 | | - } |
| 238 | + $this->check_version(); |
246 | 239 | } |
247 | 240 |
|
248 | 241 | /** |
@@ -801,19 +794,19 @@ function enqueue_scripts() { |
801 | 794 | $rangyinputs_suffix = defined( "SCRIPT_DEBUG" ) && SCRIPT_DEBUG ? '-src' : ''; |
802 | 795 |
|
803 | 796 | // Load IE8 Array.prototype.reduceRight polyfill for unorm. |
804 | | - wp_enqueue_script( 'unfc-ie8', plugins_url( "js/ie8{$suffix}.js", __FILE__ ), array(), UNFC_VERSION ); |
| 797 | + wp_enqueue_script( 'unfc-ie8', plugins_url( "js/ie8{$suffix}.js", UNFC_FILE ), array(), UNFC_VERSION ); |
805 | 798 |
|
806 | 799 | global $wp_scripts; // For < 4.2 compat, don't use wp_script_add_data(). |
807 | 800 | $wp_scripts->add_data( 'unfc-ie8', 'conditional', 'lt IE 9' ); |
808 | 801 |
|
809 | 802 | // Load the javascript normalize polyfill https://github.com/walling/unorm |
810 | | - wp_enqueue_script( 'unfc-unorm', plugins_url( "unorm/lib/unorm.js", __FILE__ ), array( 'unfc-ie8' ), '1.4.1' ); // Note unorm doesn't come with minified so don't use. |
| 803 | + wp_enqueue_script( 'unfc-unorm', plugins_url( "unorm/lib/unorm.js", UNFC_FILE ), array( 'unfc-ie8' ), '1.4.1' ); // Note unorm doesn't come with minified so don't use. |
811 | 804 |
|
812 | 805 | // Load the getSelection/setSelection jquery plugin https://github.com/timdown/rangyinputs |
813 | | - wp_enqueue_script( 'unfc-rangyinputs', plugins_url( "rangyinputs/rangyinputs-jquery{$rangyinputs_suffix}.js", __FILE__ ), array( 'jquery' ), '1.2.0' ); |
| 806 | + wp_enqueue_script( 'unfc-rangyinputs', plugins_url( "rangyinputs/rangyinputs-jquery{$rangyinputs_suffix}.js", UNFC_FILE ), array( 'jquery' ), '1.2.0' ); |
814 | 807 |
|
815 | 808 | // Our script. Normalizes on paste in tinymce and in admin input/textareas and in some media stuff and in front-end input/textareas. |
816 | | - wp_enqueue_script( 'unfc-normalize', plugins_url( "js/unfc-normalize{$suffix}.js", __FILE__ ), array( 'jquery', 'unfc-rangyinputs', 'unfc-unorm' ), UNFC_VERSION ); |
| 809 | + wp_enqueue_script( 'unfc-normalize', plugins_url( "js/unfc-normalize{$suffix}.js", UNFC_FILE ), array( 'jquery', 'unfc-rangyinputs', 'unfc-unorm' ), UNFC_VERSION ); |
817 | 810 |
|
818 | 811 | // Our parameters. |
819 | 812 | $params = array( |
@@ -1281,7 +1274,7 @@ function db_check_print_normalize_form() { |
1281 | 1274 | */ |
1282 | 1275 | function db_check_print_items_list() { |
1283 | 1276 | if ( ! class_exists( 'UNFC_DB_Check_Items_List_Table' ) ) { |
1284 | | - require self::$dirname . '/class-unfc-db_check-list-table.php'; |
| 1277 | + require self::$dirname . '/includes/class-unfc-db_check-list-table.php'; |
1285 | 1278 | } |
1286 | 1279 | if ( $this->db_check_num_items > count( $this->db_check_items ) ) { |
1287 | 1280 | $h2 = sprintf( |
@@ -1345,7 +1338,7 @@ function db_check_print_slug_form( $rescan = false ) { |
1345 | 1338 | */ |
1346 | 1339 | function db_check_print_slugs_list() { |
1347 | 1340 | if ( ! class_exists( 'UNFC_DB_Check_Slugs_List_Table' ) ) { |
1348 | | - require self::$dirname . '/class-unfc-db_check-list-table.php'; |
| 1341 | + require self::$dirname . '/includes/class-unfc-db_check-list-table.php'; |
1349 | 1342 | } |
1350 | 1343 | if ( $this->db_check_num_slugs > count( $this->db_check_slugs ) ) { |
1351 | 1344 | $h2 = sprintf( |
@@ -1389,10 +1382,10 @@ function db_check_button() { |
1389 | 1382 | if ( isset( $_REQUEST['unfc_db_check_slugs'] ) ) { |
1390 | 1383 | return 'unfc_db_check_slugs'; |
1391 | 1384 | } |
1392 | | - if ( isset( $_REQUEST['action'] ) && 'unfc_db_check_normalize_slugs' === $_REQUEST['action'] ) { |
| 1385 | + if ( isset( $_REQUEST['action'] ) && is_string( $_REQUEST['action'] ) && 'unfc_db_check_normalize_slugs' === $_REQUEST['action'] ) { |
1393 | 1386 | return 'unfc_db_check_normalize_slugs'; |
1394 | 1387 | } |
1395 | | - if ( isset( $_REQUEST['action2'] ) && 'unfc_db_check_normalize_slugs' === $_REQUEST['action2'] ) { |
| 1388 | + if ( isset( $_REQUEST['action2'] ) && is_string( $_REQUEST['action2'] ) && 'unfc_db_check_normalize_slugs' === $_REQUEST['action2'] ) { |
1396 | 1389 | return 'unfc_db_check_normalize_slugs'; |
1397 | 1390 | } |
1398 | 1391 | if ( isset( $_REQUEST['screen-options-apply'] ) && isset( $_REQUEST['wp_screen_options'] ) && is_array( $_REQUEST['wp_screen_options'] ) ) { |
@@ -1604,7 +1597,7 @@ function db_check_items( &$admin_notices ) { |
1604 | 1597 | if ( $have_field ) { |
1605 | 1598 | if ( $ret['num_items'] < $list_limit ) { |
1606 | 1599 | $title = $obj->{$this->db_title_cols[ $type ]}; |
1607 | | - if ( mb_strlen( $title ) > UNFC_DB_CHECK_TITLE_MAX_LEN ) { |
| 1600 | + if ( mb_strlen( $title, 'UTF-8' ) > UNFC_DB_CHECK_TITLE_MAX_LEN ) { |
1608 | 1601 | $title = mb_substr( $title, 0, UNFC_DB_CHECK_TITLE_MAX_LEN, 'UTF-8' ) . __( '...', 'unfc-normalize' ); |
1609 | 1602 | } |
1610 | 1603 | $ret['items'][] = array( |
@@ -2040,7 +2033,7 @@ function db_check_slugs( &$admin_notices ) { |
2040 | 2033 | if ( ! ( $this->no_normalizer ? unfc_normalizer_is_normalized( $decoded ) : normalizer_is_normalized( $decoded ) ) ) { |
2041 | 2034 | if ( $ret['num_slugs'] < $list_limit ) { |
2042 | 2035 | $title = $obj->title; |
2043 | | - if ( mb_strlen( $title ) > UNFC_DB_CHECK_TITLE_MAX_LEN ) { |
| 2036 | + if ( mb_strlen( $title, 'UTF-8' ) > UNFC_DB_CHECK_TITLE_MAX_LEN ) { |
2044 | 2037 | $title = mb_substr( $title, 0, UNFC_DB_CHECK_TITLE_MAX_LEN, 'UTF-8' ) . __( '...', 'unfc-normalize' ); |
2045 | 2038 | } |
2046 | 2039 | $ret['slugs'][] = array( |
|
0 commit comments