positions like 'k', 's', 'v' or 'z'. Version: 1.4.7 Author: Honza Skypala Author URI: http://www.honza.info/ */ include_once(ABSPATH . 'wp-admin/includes/plugin.php'); class Zalomeni { const version = '1.4.7'; public function __construct() { register_activation_hook(__FILE__, array($this, 'activate')); if (is_admin()){ add_action('admin_init', array($this, 'admin_init')); } else { add_action('init', array($this, 'add_filters')); } } public function add_filters() { $zalomeni_matches = get_option('zalomeni_matches'); if (!empty($zalomeni_matches)) { $filters = array('comment_author', 'term_name', 'link_name', 'link_description', 'link_notes', 'bloginfo', 'wp_title', 'widget_title', 'term_description', 'the_title', 'the_content', 'the_excerpt', 'comment_text', 'single_post_title', 'list_cats'); $filters = array_combine($filters, $filters); $filters = apply_filters('zalomeni_filtry', $filters); foreach ($filters as $filter) { add_filter($filter, array($this, 'texturize')); // content filter } } } static function activate() { $required_php_version = '5.3'; if (version_compare(phpversion(), $required_php_version, '<')) die(str_replace(array("%1", "%2"), array($required_php_version, phpversion()), __("Plugin Zalomení vyžaduje PHP verze %1 nebo vyšší. Na tomto webu je nainstalováno PHP verze %2", "zalomeni"))); self::add_options(); } const default_prepositions = 'on'; const default_prepositions_list = 'k, s, v, z'; const default_conjunctions = ''; const default_conjunctions_list = 'a, i, o, u'; const default_abbreviations = ''; const default_abbreviations_list = 'cca., č., čís., čj., čp., fa, fě, fy, kupř., mj., např., p., pí, popř., př., přib., přibl., sl., str., sv., tj., tzn., tzv., zvl.'; const default_between_number_and_unit = 'on'; const default_between_number_and_unit_list = 'm, m², l, kg, h, °C, Kč, lidí, dní, %'; const default_spaces_in_scales = 'on'; const default_space_between_numbers = 'on'; const default_space_after_ordered_number = 'on'; const default_custom_terms = "Formule 1\nWindows \d\niPhone \d\niPhone S\d\niPad \d\nWii U\nPlayStation \d\nXBox 360"; static function add_options() { add_option('zalomeni_version', self::version); add_option('zalomeni_prepositions', Zalomeni::default_prepositions); add_option('zalomeni_prepositions_list', Zalomeni::default_prepositions_list); add_option('zalomeni_conjunctions', Zalomeni::default_conjunctions); add_option('zalomeni_conjunctions_list', Zalomeni::default_conjunctions_list); add_option('zalomeni_abbreviations', Zalomeni::default_abbreviations); add_option('zalomeni_abbreviations_list', Zalomeni::default_abbreviations_list); add_option('zalomeni_between_number_and_unit', Zalomeni::default_between_number_and_unit); add_option('zalomeni_between_number_and_unit_list', Zalomeni::default_between_number_and_unit_list); add_option('zalomeni_spaces_in_scales', Zalomeni::default_spaces_in_scales); add_option('zalomeni_space_between_numbers', Zalomeni::default_space_between_numbers); add_option('zalomeni_space_after_ordered_number', Zalomeni::default_space_after_ordered_number); add_option('zalomeni_custom_terms', Zalomeni::default_custom_terms); self::update_matches_and_replacements(); } private function update_plugin_version() { $registered_version = get_option('zalomeni_version', '0'); if ($registered_version == '0') return; if (version_compare($registered_version, self::version, '<')) { if (version_compare($registered_version, '1.3', '<')) { $old_options = get_option('zalomeni_options'); update_option('zalomeni_prepositions', $old_options['zalomeni_prepositions']); update_option('zalomeni_prepositions_list', $old_options['zalomeni_prepositions_list']); update_option('zalomeni_conjunctions', $old_options['zalomeni_conjunctions']); update_option('zalomeni_conjunctions_list', $old_options['zalomeni_conjunctions_list']); if (!version_compare($registered_version, '1.1', '<')) { // these options were introduced in version 1.1 update_option('zalomeni_abbreviations', $old_options['zalomeni_abbreviations']); update_option('zalomeni_abbreviations_list', $old_options['zalomeni_abbreviations_list']); update_option('zalomeni_space_between_numbers', $old_options['zalomeni_numbers']); } delete_option('zalomeni_options'); } self::add_options(); update_option('zalomeni_version', self::version); } } protected static $this_plugin; function add_settings_to_plugin_actions($links, $file) { // Add settings link to plugin list for this plugin if (!self::$this_plugin) self::$this_plugin = plugin_basename(__FILE__); if ($file == self::$this_plugin) { $settings_link = '' . __('Settings') . ''; array_unshift( $links, $settings_link ); // before other links } return $links; } function admin_init() { $this->update_plugin_version(); add_filter('plugin_action_links', array($this, 'add_settings_to_plugin_actions'), 10, 2); // link from Plugins list admin page to settings of this plugin register_setting('reading', 'zalomeni_prepositions'); register_setting('reading', 'zalomeni_prepositions_list'); register_setting('reading', 'zalomeni_conjunctions'); register_setting('reading', 'zalomeni_conjunctions_list'); register_setting('reading', 'zalomeni_abbreviations'); register_setting('reading', 'zalomeni_abbreviations_list'); register_setting('reading', 'zalomeni_between_number_and_unit'); register_setting('reading', 'zalomeni_between_number_and_unit_list'); register_setting('reading', 'zalomeni_space_between_numbers'); register_setting('reading', 'zalomeni_space_after_ordered_number'); register_setting('reading', 'zalomeni_spaces_in_scales'); register_setting('reading', 'zalomeni_custom_terms'); add_settings_section('zalomeni_section', $this->texturize(__('Nevhodná slova a zalomení na konci řádku', 'zalomeni')), 'Zalomeni::settings_section_description', 'reading'); add_settings_field('zalomeni_prepositions', __('Předložky', 'zalomeni'), 'Zalomeni::settings_field_checkbox', 'reading', 'zalomeni_section', array('option'=>'prepositions', 'description'=>"Vkládat pevnou mezeru za následující předložky.", 'toggle_list_read_only'=>true)); add_settings_field('zalomeni_prepositions_list', '', 'Zalomeni::settings_field_textlist', 'reading', 'zalomeni_section', array('option'=>'prepositions', 'description'=>"(oddělte jednotlivé předložky čárkou)")); add_settings_field('zalomeni_conjunctions', __('Spojky', 'zalomeni'), 'Zalomeni::settings_field_checkbox', 'reading', 'zalomeni_section', array('option'=>'conjunctions', 'description'=>"Vkládat pevnou mezeru za následující spojky.", 'toggle_list_read_only'=>true)); add_settings_field('zalomeni_conjunctions_list', '', 'Zalomeni::settings_field_textlist', 'reading', 'zalomeni_section', array('option'=>'conjunctions', 'description'=>"(oddělte jednotlivé spojky čárkou)")); add_settings_field('zalomeni_abbreviations', __('Zkratky', 'zalomeni'), 'Zalomeni::settings_field_checkbox', 'reading', 'zalomeni_section', array('option'=>'abbreviations', 'description'=>"Vkládat pevnou mezeru za následující zkratky.", 'toggle_list_read_only'=>true)); add_settings_field('zalomeni_abbreviations_list', '', 'Zalomeni::settings_field_textlist', 'reading', 'zalomeni_section', array('option'=>'abbreviations', 'description'=>"(oddělte jednotlivé zkratky čárkou)")); add_settings_field('zalomeni_between_number_and_unit', __('Jednotky a míry', 'zalomeni'), 'Zalomeni::settings_field_checkbox', 'reading', 'zalomeni_section', array('option'=>'between_number_and_unit', 'description'=>"Vkládat pevnou mezeru mezi číslovku a jednotku míry (měrné jednotky, měna apod., např. 5 m nebo 10 kg).", 'toggle_list_read_only'=>true)); add_settings_field('zalomeni_between_number_and_unit_list', '', 'Zalomeni::settings_field_textlist', 'reading', 'zalomeni_section', array('option'=>'between_number_and_unit', 'description'=>"(oddělte jednotlivé míry čárkou)")); add_settings_field('zalomeni_space_between_numbers', __('Mezery uprostřed čísel', 'zalomeni'), 'Zalomeni::settings_field_checkbox', 'reading', 'zalomeni_section', array('option'=>'space_between_numbers', 'description'=>"Pokud jsou dvě čísla oddělena mezerou, předpokládat, že se jedná o formátování čísla pomocí mezery (např. telefonní číslo 800 123 456) a nahrazovat mezeru pevnou mezerou, aby nedošlo k zalomení řádku uprostřed čísla.")); add_settings_field('zalomeni_space_after_ordered_number', __('Řadové číslovky', 'zalomeni'), 'Zalomeni::settings_field_checkbox', 'reading', 'zalomeni_section', array('option'=>'space_after_ordered_number', 'description'=>"Zabránit zalomení řádku za řadovou číslovkou; díky tomu nedojde k zalomení řádku uprostřed data (např. 1. ledna) a v podobných případech (19. ročník, 3. svazek, 5. kapitola apod.)")); add_settings_field('zalomeni_spaces_in_scales', __('Měřítka a poměry', 'zalomeni'), 'Zalomeni::settings_field_checkbox', 'reading', 'zalomeni_section', array('option'=>'spaces_in_scales', 'description'=>"Pevné mezery v měřítkách a poměrech (např. 1 : 50 000)")); add_settings_field('zalomeni_custom_terms', __('Vlastní výrazy', 'zalomeni'), 'Zalomeni::settings_field_custom_terms', 'reading', 'zalomeni_section'); if (get_option('zalomeni_matches') == '') { Zalomeni::update_matches_and_replacements(); } $this->add_update_option_hooks(); } static public function settings_field_checkbox(array $args) { echo( ' ' . Zalomeni::texturize(__($args['description'], 'zalomeni')) ); } static public function settings_field_textlist(array $args) { echo( ' ' . Zalomeni::texturize(__($args['description'], 'zalomeni')) ); } static public function settings_field_custom_terms() { echo( Zalomeni::texturize(__('Zde můžete uvést vlastní termíny, v nichž mají být mezery nahrazeny pevnými mezerami tak, aby nedošlo k zalomení uvnitř těchto výrazů. Uveďte vždy každý výraz na samostatný řádek; pokud je výraz složen z více jak dvou slov, tedy je v něm více jak jedna mezera, pak všechny mezery budou nahrazeny za pevné mezery. Lze použít výrazu \\d pro libovolnou číslici (pro pokročilé administrátory: algoritmus používá Perl Compatible Regular Expressions, lze využít syntaxe této specifikace).', 'zalomeni')) . '

' ); } private function add_update_option_hooks() { foreach (array('update_option_zalomeni_prepositions', 'update_option_zalomeni_prepositions_list', 'update_option_zalomeni_conjunctions', 'update_option_zalomeni_conjunctions_list', 'update_option_zalomeni_abbreviations', 'update_option_zalomeni_abbreviations_list', 'update_option_zalomeni_between_number_and_unit', 'update_option_zalomeni_between_number_and_unit_list', 'update_option_zalomeni_space_between_numbers', 'update_option_zalomeni_space_after_ordered_number', 'update_option_zalomeni_spaces_in_scales', 'update_option_zalomeni_custom_terms') as $i) { add_action($i, array($this, 'update_matches_and_replacements')); } } public function update_matches_and_replacements() { update_option('zalomeni_matches', Zalomeni::prepare_matches()); update_option('zalomeni_replacements', Zalomeni::prepare_replacements()); } private function prepare_matches() { $return_array = array(); $word_matches = ''; foreach (array('prepositions', 'conjunctions', 'abbreviations') as $i) { if (get_option('zalomeni_'.$i, constant('Zalomeni::default_'.$i)) == 'on') { $temp_array = explode(',', get_option('zalomeni_'.$i.'_list', constant('Zalomeni::default_'.$i.'_list'))); foreach ($temp_array as $j) { $j = mb_strtolower(trim($j)); $word_matches .= ($word_matches == '' ? '' : '|') . $j; } } } if ($word_matches != '') { $return_array['words'] = '@($|;| | |\(|\n)('.$word_matches.') @i'; } $word_matches = ''; if (get_option('zalomeni_between_number_and_unit', Zalomeni::default_between_number_and_unit) == 'on') { $temp_array = explode(',', get_option('zalomeni_between_number_and_unit_list', Zalomeni::default_between_number_and_unit_list)); foreach ($temp_array as $j) { $j = mb_strtolower(trim($j)); $word_matches .= ($word_matches == '' ? '' : '|') . $j; } } if ($word_matches != '') { $return_array['units'] = '@(\d) ('.$word_matches.')(^|[;\.!:]| | |\?|\n|\)|<|\010|\013|$)@i'; } if (get_option('zalomeni_space_between_numbers', Zalomeni::default_space_between_numbers) == 'on') { $return_array['numbers'] = '@(\d) (\d)@i'; } if (get_option('zalomeni_spaces_in_scales', Zalomeni::default_spaces_in_scales) == 'on') { $return_array['scales'] = '@(\d) : (\d)@i'; } if (get_option('zalomeni_space_after_ordered_number', Zalomeni::default_space_after_ordered_number) == 'on') { $return_array['orders'] = '@(\d\.) ([0-9a-záčďéěíňóřšťúýž])@'; } if (get_option('zalomeni_custom_terms', Zalomeni::default_custom_terms) != '') { $term_counter = 1; $custom_terms = explode(chr(10), str_replace(chr(13), '', get_option('zalomeni_custom_terms', Zalomeni::default_custom_terms))); foreach ($custom_terms as $i) { if (strpos($i, ' ') !== false) { $term = ''; $words_split = explode(' ', $i); foreach ($words_split as $j) { $term .= ($term == '' ? '(' : ' (') . str_replace(array('/', '(', ')'), array('\\/', '\\(', '\\)'), $j) . ')'; } $term = '/' . $term . '/i'; $return_array['customterm' . $term_counter++] = $term; } } } return $return_array; } private function prepare_replacements() { $return_array = array(); foreach (array('prepositions', 'conjunctions', 'abbreviations') as $i) { if (get_option('zalomeni_'.$i, constant('Zalomeni::default_'.$i)) == 'on') { $return_array['words'] = '$1$2 '; break; } } if (get_option('zalomeni_between_number_and_unit', Zalomeni::default_between_number_and_unit) == 'on') { $return_array['units'] = '$1 $2$3'; } if (get_option('zalomeni_space_between_numbers', Zalomeni::default_space_between_numbers) == 'on') { $return_array['numbers'] = '$1 $2'; } if (get_option('zalomeni_spaces_in_scales', Zalomeni::default_spaces_in_scales) == 'on') { $return_array['scales'] = '$1 : $2'; } if (get_option('zalomeni_space_after_ordered_number', Zalomeni::default_space_after_ordered_number) == 'on') { $return_array['orders'] = '$1 $2'; } if (get_option('zalomeni_custom_terms', Zalomeni::default_custom_terms) != '') { $term_counter = 1; $custom_terms = explode(chr(10), str_replace(chr(13), '', get_option('zalomeni_custom_terms', Zalomeni::default_custom_terms))); foreach ($custom_terms as $i) { if (strpos($i, ' ') !== false) { $term = ''; $words_split = explode(' ', $i); $word_counter = 1; foreach ($words_split as $j) { $term .= ($term == '' ? '' : ' ') . '$' . $word_counter++; } $return_array['customterm' . $term_counter++] = $term; } } } return $return_array; } static public function settings_section_description() { echo( '
' . '

Plugin Zalomení
Autor: Honza Skýpala

' . '
' . '

' . Zalomeni::texturize(__('Upravujeme-li písemný dokument, radí nám Pravidla českého pravopisu nepsat neslabičné předložky v, s, z, k na konec řádku, ale psát je na stejný řádek se slovem, které nese přízvuk (např. ve spojení k mostu, s bratrem, v Plzni, z nádraží). Typografické normy jsou ještě přísnější: podle některých je nepatřičné ponechat na konci řádku jakékoli jednopísmenné slovo, tedy také předložky a spojky a, i, o, u;. Někteří pisatelé dokonce nechtějí z estetických důvodů ponechávat na konci řádků jakékoli jednoslabičné výrazy (např. ve, ke, ku, že, na, do, od, pod).', 'zalomeni')) . '

' . '

' . Zalomeni::texturize(__('Více informací na webu Ústavu pro jazyk český, Akademie věd ČR.', 'zalomeni')) . '

' . '

' . Zalomeni::texturize(__('Tento plugin řeší některé z uvedených příkladů: v textu nahrazuje běžné mezery za pevné tak, aby nedošlo k zalomení řádku v nevhodném místě.', 'zalomeni')) . '

' ); } static public function texturize($text) { if (get_option('zalomeni_matches') == '') return $text; // no settings? then fall-back to just return the content $output = ''; $curl = ''; $textarr = preg_split('/(<.*>|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE); $stop = count($textarr); $no_texturize_tags = apply_filters('no_texturize_tags', array('pre', 'code', 'kbd', 'style', 'script', 'tt')); $no_texturize_shortcodes = apply_filters('no_texturize_shortcodes', array('code')); $no_texturize_tags_stack = array(); $no_texturize_shortcodes_stack = array(); for ($i = 0; $i < $stop; $i++) { $curl = $textarr[$i]; if (!empty($curl)) { global $wp_version; if ('<' != $curl{0} && '[' != $curl{0} && empty($no_texturize_shortcodes_stack) && empty($no_texturize_tags_stack)) { // If it's not a tag $curl = preg_replace(get_option('zalomeni_matches'), get_option('zalomeni_replacements'), $curl); $curl = preg_replace(get_option('zalomeni_matches'), get_option('zalomeni_replacements'), $curl); } else if (version_compare($wp_version, '2.9', '<')) { wptexturize_pushpop_element($curl, $no_texturize_tags_stack, $no_texturize_tags, '<', '>'); wptexturize_pushpop_element($curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes, '[', ']'); } else { _wptexturize_pushpop_element($curl, $no_texturize_tags_stack, $no_texturize_tags, '<', '>'); _wptexturize_pushpop_element($curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes, '[', ']'); } } $output .= $curl; } return $output; } } $wpZalomeni = new Zalomeni(); ?>_opt']['link'], 'Cookie Notice', 'Custom link' ); // WPML and Polylang compatibility } elseif ( function_exists( 'icl_t' ) ) { $this->options['general']['message_text'] = icl_t( 'Cookie Notice', 'Message in the notice', $this->options['general']['message_text'] ); $this->options['general']['accept_text'] = icl_t( 'Cookie Notice', 'Button text', $this->options['general']['accept_text'] ); $this->options['general']['refuse_text'] = icl_t( 'Cookie Notice', 'Refuse button text', $this->options['general']['refuse_text'] ); $this->options['general']['revoke_text'] = icl_t( 'Cookie Notice', 'Revoke button text', $this->options['general']['revoke_text'] ); $this->options['general']['see_more_opt']['text'] = icl_t( 'Cookie Notice', 'Privacy policy text', $this->options['general']['see_more_opt']['text'] ); $this->options['general']['see_more_opt']['link'] = icl_t( 'Cookie Notice', 'Custom link', $this->options['general']['see_more_opt']['link'] ); } if ( function_exists( 'icl_object_id' ) ) $this->options['general']['see_more_opt']['id'] = icl_object_id( $this->options['general']['see_more_opt']['id'], 'page', true ); // get cookie container args $options = apply_filters( 'cn_cookie_notice_args', array( 'position' => $this->options['general']['position'], 'css_style' => $this->options['general']['css_style'], 'css_class' => $this->options['general']['css_class'], 'button_class' => 'cn-button', 'colors' => $this->options['general']['colors'], 'message_text' => $this->options['general']['message_text'], 'accept_text' => $this->options['general']['accept_text'], 'refuse_text' => $this->options['general']['refuse_text'], 'revoke_text' => $this->options['general']['revoke_text'], 'refuse_opt' => $this->options['general']['refuse_opt'], 'see_more' => $this->options['general']['see_more'], 'see_more_opt' => $this->options['general']['see_more_opt'], 'link_target' => $this->options['general']['link_target'], ) ); $options['css_class'] = esc_attr( $options['css_class'] ); // message output $output = ' '; echo apply_filters( 'cn_cookie_notice_output', $output, $options ); } } /** * Check if cookies are accepted. * * @return bool */ public static function cookies_accepted() { return apply_filters( 'cn_is_cookie_accepted', isset( $_COOKIE['cookie_notice_accepted'] ) && $_COOKIE['cookie_notice_accepted'] === 'true' ); } /** * Check if cookies are set. * * @return boolean Whether cookies are set */ public function cookies_set() { return apply_filters( 'cn_is_cookie_set', isset( $_COOKIE['cookie_notice_accepted'] ) ); } /** * Get default settings. */ public function get_defaults() { return $this->defaults; } /** * Add links to support forum. * * @param array $links * @param string $file * @return array */ public function plugin_row_meta( $links, $file ) { if ( ! current_user_can( apply_filters( 'cn_manage_cookie_notice_cap', 'manage_options' ) ) ) return $links; if ( $file == plugin_basename( __FILE__ ) ) return array_merge( $links, array( sprintf( '%s', __( 'Support', 'cookie-notice' ) ) ) ); return $links; } /** * Add links to settings page. * * @param array $links * @param string $file * @return array */ public function plugin_action_links( $links, $file ) { if ( ! current_user_can( apply_filters( 'cn_manage_cookie_notice_cap', 'manage_options' ) ) ) return $links; if ( $file == plugin_basename( __FILE__ ) ) array_unshift( $links, sprintf( '%s', admin_url( 'options-general.php?page=cookie-notice' ), __( 'Settings', 'cookie-notice' ) ) ); return $links; } /** * Activate the plugin. */ public function activation() { add_option( 'cookie_notice_options', $this->defaults['general'], '', 'no' ); add_option( 'cookie_notice_version', $this->defaults['version'], '', 'no' ); } /** * Deactivate the plugin. */ public function deactivation() { if ( $this->options['general']['deactivation_delete'] === 'yes' ) delete_option( 'cookie_notice_options' ); } /** * Get allowed script blocking HTML. * * @return array */ public function get_allowed_html() { return apply_filters( 'cn_refuse_code_allowed_html', array_merge( wp_kses_allowed_html( 'post' ), array( 'script' => array( 'type' => array(), 'src' => array(), 'charset' => array(), 'async' => array() ), 'noscript' => array(), 'style' => array( 'type' => array() ), 'iframe' => array( 'src' => array(), 'height' => array(), 'width' => array(), 'frameborder' => array(), 'allowfullscreen' => array() ) ) ) ); } /** * Load scripts and styles - admin. */ public function admin_enqueue_scripts( $page ) { if ( $page !== 'settings_page_cookie-notice' ) return; wp_enqueue_script( 'cookie-notice-admin', plugins_url( 'js/admin' . ( ! ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', __FILE__ ), array( 'jquery', 'wp-color-picker' ), $this->defaults['version'] ); wp_localize_script( 'cookie-notice-admin', 'cnArgs', array( 'resetToDefaults' => __( 'Are you sure you want to reset these settings to defaults?', 'cookie-notice' ) ) ); wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_style( 'cookie-notice-admin', plugins_url( 'css/admin' . ( ! ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.min' : '' ) . '.css', __FILE__ ) ); } /** * Load scripts and styles - frontend. */ public function wp_enqueue_scripts() { wp_enqueue_script( 'cookie-notice-front', plugins_url( 'js/front' . ( ! ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', __FILE__ ), array( 'jquery' ), $this->defaults['version'], isset( $this->options['general']['script_placement'] ) && $this->options['general']['script_placement'] === 'footer' ? true : false ); wp_localize_script( 'cookie-notice-front', 'cnArgs', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'hideEffect' => $this->options['general']['hide_effect'], 'onScroll' => $this->options['general']['on_scroll'], 'onScrollOffset' => $this->options['general']['on_scroll_offset'], 'cookieName' => 'cookie_notice_accepted', 'cookieValue' => 'true', 'cookieTime' => $this->times[$this->options['general']['time']][1], 'cookiePath' => ( defined( 'COOKIEPATH' ) ? COOKIEPATH : '' ), 'cookieDomain' => ( defined( 'COOKIE_DOMAIN' ) ? COOKIE_DOMAIN : '' ), 'redirection' => $this->options['general']['redirection'], 'cache' => defined( 'WP_CACHE' ) && WP_CACHE, 'refuse' => $this->options['general']['refuse_opt'], 'revoke_cookies' => (int) $this->options['general']['revoke_cookies'], 'revoke_cookies_opt' => $this->options['general']['revoke_cookies_opt'], 'secure' => (int) is_ssl() ) ); wp_enqueue_style( 'cookie-notice-front', plugins_url( 'css/front' . ( ! ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.min' : '' ) . '.css', __FILE__ ) ); } /** * Print non functional JavaScript in body. * * @return mixed */ public function wp_print_footer_scripts() { if ( $this->cookies_accepted() ) { $scripts = apply_filters( 'cn_refuse_code_scripts_html', html_entity_decode( trim( wp_kses( $this->options['general']['refuse_code'], $this->get_allowed_html() ) ) ) ); if ( ! empty( $scripts ) ) echo $scripts; } } /** * Print non functional JavaScript in header. * * @return mixed */ public function wp_print_header_scripts() { if ( $this->cookies_accepted() ) { $scripts = apply_filters( 'cn_refuse_code_scripts_html', html_entity_decode( trim( wp_kses( $this->options['general']['refuse_code_head'], $this->get_allowed_html() ) ) ) ); if ( ! empty( $scripts ) ) echo $scripts; } } }PNG  IHDR ,y} IDATxy?\S@@唛03#^I>11[1js(|`;Jz <`OdWN][\1TNʖ6:Li M c^TTp8>tp8 7 gU fȊK>#ۿdBCi葄̋{Os}uEhOT{5y`聉YoufM;nÅ}P -:8tWeƌ# .'~ V^J=vkIA (Dss2o`t}*>yCHdMBs61) ?4g'gc? <t-{(>Kܿ=#w@+ȼ,*PV:lVeYbØ`UyCՒ6Y#]8"eNYbTy~dz3(;]+]KϺt톙 7!5*.ڱ,IL|ƌED\1l,9++Ge cƔOo{̥k=rR-3_76M+Wd|99|^@O73MHzQ/ Lݤ+ef͚e n;53hʕ壚Ej1/ok[EyQDWㅯkklm-a[KKV|M%>(au;[W=MHq!|1օ16EJinpHs5k0,`3XZ,dj17w5\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%b^mSJplGʊ\7.Ez:tIDATfs[$.#Inݘs|>; m' p!\&eefM7IX\NhM>oiaBZXʇ= b%F_ ΁Q2JuȄ# $0fI;e`?̂s#q ӞZ~xg{~8ZkMƞuزA,0y{+oyw]Wto_y`]ZZ:`T A% <ά]`lxxxbA7STr'^aHHJEaK"F!!TD#dY0v8ݓ]ynY1qIENDB` $stars = is_numeric($_POST['stars']) && ((int)$_POST['stars']>0) && ((int)$_POST['stars']<=$total_stars) ? $_POST['stars']: 0; $ip = $_SERVER['REMOTE_ADDR']; $Ids = explode(',', $_POST['id']); foreach($Ids as $pid) : $ratings = get_post_meta($pid, '_kksr_ratings', true) ? get_post_meta($pid, '_kksr_ratings', true) : 0; $casts = get_post_meta($pid, '_kksr_casts', true) ? get_post_meta($pid, '_kksr_casts', true) : 0; if($stars==0 && $ratings==0) { $Response[$pid]['legend'] = parent::get_options('kksr_init_msg'); $Response[$pid]['disable'] = 'false'; $Response[$pid]['fuel'] = '0'; do_action('kksr_init', $pid, false, false); } else { $nratings = $ratings + ($stars/($total_stars/5)); $ncasts = $casts + ($stars>0); $avg = $nratings && $ncasts ? number_format((float)($nratings/$ncasts), 2, '.', '') : 0; $per = $nratings && $ncasts ? number_format((float)((($nratings/$ncasts)/5)*100), 2, '.', '') : 0; $Response[$pid]['disable'] = 'false'; if($stars) { $Ips = get_post_meta($pid, '_kksr_ips', true) ? unserialize(base64_decode(get_post_meta($pid, '_kksr_ips', true))) : array(); if(!in_array($ip, $Ips)) { $Ips[] = $ip; } $ips = base64_encode(serialize($Ips)); update_post_meta($pid, '_kksr_ratings', $nratings); update_post_meta($pid, '_kksr_casts', $ncasts); update_post_meta($pid, '_kksr_ips', $ips); update_post_meta($pid, '_kksr_avg', $avg); $Response[$pid]['disable'] = parent::get_options('kksr_unique') ? 'true' : 'false'; do_action('kksr_rate', $pid, $stars, $ip); } else { do_action('kksr_init', $pid, number_format((float)($avg*($total_stars/5)), 2, '.', '').'/'.$total_stars, $ncasts); } // $legend = parent::get_options('kksr_legend'); // $legend = str_replace('[total]', $ncasts, $legend); // $legend = str_replace('[avg]', number_format((float)($avg*($total_stars/5)), 2, '.', '').'/'.$total_stars, $legend); // $legend = str_replace('[s]', $ncasts==1?'':'s', $legend); // $Response[$pid]['legend'] = str_replace('[per]',$per.'%', $legend); // $Response[$pid]['legend'] = apply_filters('kksr_legend', parent::get_options('kksr_legend'), $pid); $Response[$pid]['meta'] = $this->extract_ratings($pid); $Response[$pid]['legend'] = $this->ratings_as_legend($pid, $Response[$pid]['meta']); $Response[$pid]['fuel'] = (float) $per; } $Response[$pid]['success'] = true; endforeach; echo json_encode($Response); die(); } protected function trim_csv_cb($value) { if(trim($value)!="") return true; return false; } protected function exclude_cat($id) { $excl_categories = parent::get_options('kksr_exclude_categories'); $Cat_ids = $excl_categories ? array_filter(array_map('trim', explode(",", $excl_categories)), array(&$this, 'trim_csv_cb')) : array(); $Post_cat_ids = wp_get_post_categories($id); $Intersection = array_intersect($Cat_ids, $Post_cat_ids); return count($Intersection); } public function markup($id=false) { $id = !$id ? get_the_ID() : $id; if($this->exclude_cat($id)) { return ''; } $disabled = false; if(get_post_meta($id, '_kksr_ips', true)) { $Ips = unserialize(base64_decode(get_post_meta($id, '_kksr_ips', true))); $ip = $_SERVER['REMOTE_ADDR']; if(in_array($ip, $Ips)) { $disabled = parent::get_options('kksr_unique') ? true : false; } } $pos = parent::get_options('kksr_position'); $markup = '
'; $total_stars = parent::get_options('kksr_stars'); for($ts = 1; $ts <= $total_stars; $ts++) { $markup .= ''; } $markup .='
'; $markup .= $this->ratings_as_legend($id); $markup .= '
'; $markup .= parent::get_options('kksr_clear') ? '
' : ''; return $markup; } public function manual($atts) { extract(shortcode_atts(array('id' => false), $atts)); if(!is_admin() && parent::get_options('kksr_enable')) { if( ((parent::get_options('kksr_show_in_home')) && (is_front_page() || is_home())) || ((parent::get_options('kksr_show_in_archives')) && (is_archive())) ) return $this->markup($id); else if(is_single() || is_page()) return $this->markup($id); } else { remove_shortcode('kkratings'); remove_shortcode('kkstarratings'); } return ''; } public function filter($content) { if(parent::get_options('kksr_enable')) : if( ((parent::get_options('kksr_show_in_home')) && (is_front_page() || is_home())) || ((parent::get_options('kksr_show_in_archives')) && (is_archive())) || ((parent::get_options('kksr_show_in_posts')) && (is_single())) || ((parent::get_options('kksr_show_in_pages')) && (is_page())) ) : remove_shortcode('kkratings'); remove_shortcode('kkstarratings'); $markup = $this->markup(); if (strpos($content, '[kkratings]') !== false || strpos($content, '[kkstarratings]') !== false ) { $markup = '
' . $markup . '
'; $content = str_replace('[kkratings]', $markup, $content); $content = str_replace('[kkstarratings]', $markup, $content); return $content; } switch(parent::get_options('kksr_position')) { case 'bottom-left' : case 'bottom-right' : return $content . $markup; default : return $markup . $content; } endif; endif; return $content; } public function kk_star_rating($pid=false) { if(parent::get_options('kksr_enable')) return $this->markup($pid); return ''; } public function kk_star_ratings_get($total=5, $cat=false) { global $wpdb; $table = $wpdb->prefix . 'postmeta'; $best = (int) parent::get_options('kksr_stars'); $q = "SELECT a.ID, a.post_title, ROUND(b.meta_value * %f, 1) AS 'ratings' FROM " . $wpdb->posts . " a, $table b, "; if(!$cat) { $query = $wpdb->prepare("$q $table c WHERE a.post_status='publish' AND a.ID=b.post_id AND a.ID=c.post_id AND b.meta_key='_kksr_avg' AND c.meta_key='_kksr_casts' ORDER BY CAST(b.meta_value AS UNSIGNED) DESC, CAST(c.meta_value AS UNSIGNED) DESC LIMIT %d", $best / 5, $total); $rated_posts = $wpdb->get_results($query); } else { $table2 = $wpdb->prefix . 'term_taxonomy'; $table3 = $wpdb->prefix . 'term_relationships'; $query = $wpdb->prepare("$q $table2 c, $table3 d, $table e WHERE c.term_taxonomy_id=d.term_taxonomy_id AND c.term_id=$cat AND d.object_id=a.ID AND a.post_status='publish' AND a.ID=b.post_id AND a.ID=e.post_id AND b.meta_key='_kksr_avg' AND e.meta_key='_kksr_casts' ORDER BY CAST(b.meta_value AS UNSIGNED) DESC, CAST(e.meta_value AS UNSIGNED) DESC LIMIT %d", $best / 5, $total); $rated_posts = $wpdb->get_results($query); } return $rated_posts; } public function add_column($Columns) { if(parent::get_options('kksr_column')) $Columns['kk_star_ratings'] = 'Ratings'; return $Columns; } public function add_row($Columns, $id) { if(! parent::get_options('kksr_column')) { return; } $row = 'No ratings'; $ratings = $this->extract_ratings($id); if ($ratings['score']) { $row = $this->sanitize_legend( parent::get_options('kksr_legend'), $id, $ratings['best'], $ratings['score'], $ratings['votes'], $ratings['avg'], $ratings['per'] ); } switch($Columns) { case 'kk_star_ratings' : echo $row; break; } } /** function/method * Usage: Allow sorting of columns * Arg(1): $Args (array) * Return: (array) */ public function sort_columns($Args) { $Args = array_merge($Args, array('kk_star_ratings' => 'kk_star_ratings') ); return wp_parse_args($Args); } /** function/method * Usage: Allow sorting of columns - helper * Arg(1): $Query (array) * Return: null */ public function sort_columns_helper($Query) { if(!is_admin()) { return; } $orderby = $Query->get( 'orderby'); if($orderby=='kk_star_ratings') { $Query->set('meta_key','_kksr_avg'); $Query->set('orderby','meta_value_num'); } } public function sanitize_legend($legend, $id, $best, $score, $votes, $avg, $per) { if(!$score) { return parent::get_options('kksr_init_msg'); } $leg = str_replace('[total]', ''.$votes.'', $legend); $leg = str_replace('[avg]', ''.$avg.'', $leg); $leg = str_replace('[per]', $per .'%', $leg); $leg = str_replace('[s]', $votes == 1 ? '' : 's', $leg); $leg = str_replace('[best]', $best, $leg); return $leg; } public function grs_legend($legend, $id, $best, $score, $votes, $avg, $per) { if(!parent::get_options('kksr_grs')) { return $legend; } $title = get_the_title($id); $snippet = '
'; $snippet .= '
' . $title . '
'; $snippet .= $legend; $snippet .= ' '; $snippet .= ' '; $snippet .= '
'; $snippet .= ' '; $snippet .= '
'; $snippet .= '
'; return $snippet; } } $kkStarRatings_obj = new BhittaniPlugin_kkStarRatings('bhittani_plugin_kksr', 'kk Star Ratings', '2.6.1'); // Setup register_activation_hook(__FILE__, array($kkStarRatings_obj, 'activate')); // Scripts add_action('wp_enqueue_scripts', array($kkStarRatings_obj, 'js')); add_action('wp_enqueue_scripts', array($kkStarRatings_obj, 'css')); add_action('wp_head', array($kkStarRatings_obj, 'css_custom')); add_action('admin_init', array($kkStarRatings_obj, 'admin_scripts')); // Menu add_action('admin_menu', array($kkStarRatings_obj, 'menu')); // AJAX add_action('wp_ajax_kksr_admin_reset_ajax', array($kkStarRatings_obj, 'kksr_admin_reset_ajax')); add_action('wp_ajax_kksr_ajax', array($kkStarRatings_obj, 'kksr_ajax')); add_action('wp_ajax_nopriv_kksr_ajax', array($kkStarRatings_obj, 'kksr_ajax')); // Main Hooks add_filter('the_content', array($kkStarRatings_obj, 'filter')); add_shortcode('kkratings', array($kkStarRatings_obj, 'manual')); add_shortcode('kkstarratings', array($kkStarRatings_obj, 'manual')); // Google Rich Snippets add_filter('kksr_legend', array($kkStarRatings_obj, 'sanitize_legend'), 10, 7); add_filter('kksr_legend', array($kkStarRatings_obj, 'grs_legend'), 10, 7); // Posts/Pages Column add_filter( 'manage_posts_columns', array($kkStarRatings_obj, 'add_column') ); add_filter( 'manage_pages_columns', array($kkStarRatings_obj, 'add_column') ); add_filter( 'manage_posts_custom_column', array($kkStarRatings_obj, 'add_row'), 10, 2 ); add_filter( 'manage_pages_custom_column', array($kkStarRatings_obj, 'add_row'), 10, 2 ); add_filter( 'manage_edit-post_sortable_columns', array($kkStarRatings_obj, 'sort_columns') ); add_filter( 'pre_get_posts', array($kkStarRatings_obj, 'sort_columns_helper') ); // For use in themes if(!function_exists('kk_star_ratings')) { function kk_star_ratings($pid=false) { global $kkStarRatings_obj; return $kkStarRatings_obj->kk_star_rating($pid); } } if(!function_exists('kk_star_ratings_get')) { function kk_star_ratings_get($lim=5, $cat=false) { global $kkStarRatings_obj; return $kkStarRatings_obj->kk_star_ratings_get($lim, $cat); } } require_once 'shortcode/shortcode.php'; require_once 'widget.php'; endif;

Yet Another Related Posts Plugin Options 4.4