//allset wp-kinit )(<[^>\/][^>]*?>)/', '$1 $2', $content ); $content = strip_tags( nl2br( $content ) ); if ( preg_match( "/[\x{4e00}-\x{9fa5}]+/u", $content ) ) { $content = preg_replace( '/[\x80-\xff]{1,3}/', ' ', $content, -1, $n ); $n += str_word_count($content); return $n; } else { return count( preg_split( '/\s+/', $content ) ); } } /** * Update for all post types */ function apa_swcr_update_posts_wc_value() { if (get_option(APA_SWCR_OPTION_FIELD_KEY) == false) { // Posts apa_swcr_update_wc_posts('post'); // Pages apa_swcr_update_wc_posts('page'); // Initialized add_option(APA_SWCR_OPTION_FIELD_KEY, true); } } /** * Update Word Count on save * @param $post_id */ function apa_swcr_update_post_wc_value( $post_id ) { $content = get_post_field('post_content', $post_id); update_post_meta($post_id, APA_SWCR_META_FIELD_KEY, str_word_count($content)); } /** * Styles */ function apa_swcr_styles() { echo ''; } /** * Run plugin */ apa_swcr_sortable_word_count_run(); /** * Do some check on plugin activation. */ function apa_swcr_f_activation() { $plugin_data = get_plugin_data( __FILE__ ); $plugin_version = $plugin_data['Version']; $plugin_name = $plugin_data['Name']; $php_minimum = '5.6'; if ( version_compare( PHP_VERSION, $php_minimum, '<' ) ) { deactivate_plugins( plugin_basename( __FILE__ ) ); wp_die( '
' . __('You are using PHP version', 'apa-cf7sdomt' ) . ' ' . PHP_VERSION . '. ' . __( 'This plugin has been tested with PHP versions', 'apa-cf7sdomt' ) . ' ' . $php_minimum . ' ' . __( 'and greater.', 'apa-cf7sdomt' ) . '
' . __('WordPress itself recommends using PHP version 7.3 or greater. Please upgrade your PHP version or contact your Server administrator.', 'apa-cf7sdomt' ) . '
', __('Could not activate plugin: PHP version error', 'apa-cf7sdomt' ), array( 'back_link' => true ) ); } } register_activation_hook( __FILE__, 'apa_swcr_f_activation' ); /** * Read translations. */ function apa_swcr_f_init() { load_plugin_textdomain( 'sortable-word-count-reloaded', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); } add_action('plugins_loaded', 'apa_swcr_f_init');