/** * Counter. * * @param array $atts Shortcode attributes. * * @return string Counter in text. */ public static function counter($atts) { $count = Social_Count_Plus_Generator::get_count(); extract(shortcode_atts(array('code' => 'twitter'), $atts)); $counter = $count[$code]; return apply_filters('social_count_plus_number_format', $counter); }
/** * Widget view. * * @return string */ public static function get_view() { wp_enqueue_style('social-count-plus'); $settings = get_option('socialcountplus_settings'); $design = get_option('socialcountplus_design'); $count = Social_Count_Plus_Generator::get_count(); $color = isset($design['text_color']) ? $design['text_color'] : '#333333'; $icons = isset($design['icons']) ? array_map('sanitize_key', explode(',', $design['icons'])) : array(); $style = self::get_view_model($design['models']); $html = '<div class="social-count-plus">'; $html .= '<ul class="' . $style . '">'; foreach ($icons as $icon) { $class = 'social_count_plus_' . $icon . '_counter'; if (!isset($count[$icon])) { continue; } $total = apply_filters('social_count_plus_number_format', $count[$icon]); if (class_exists($class)) { $_class = new $class(); $html .= $_class->get_view($settings, $total, $color); } else { $html .= apply_filters('social_count_plus_' . $icon . 'html_counter', '', $settings, $total, $color); } } $html .= '</ul>'; $html .= '</div>'; return $html; }
/** * Maybe install. * * @return void */ public static function maybe_install() { $version = get_option('socialcountplus_version', '0'); if (version_compare($version, Social_Count_Plus::VERSION, '<')) { // Install options and updated old versions for 3.0.0. if (version_compare($version, '3.0.0', '<')) { foreach (self::plugin_options() as $settings_id => $sections) { $saved = get_option($settings_id, array()); foreach ($sections as $section_id => $section) { foreach ($section['fields'] as $field_id => $field) { $default = isset($field['default']) ? $field['default'] : ''; if (isset($saved[$field_id]) || '' === $default) { continue; } $saved[$field_id] = $default; } } update_option($settings_id, $saved); } // Set the icons order. $icons = self::get_current_icons(); $design = get_option('socialcountplus_design', array()); $design['icons'] = implode(',', $icons); update_option('socialcountplus_design', $design); } // Save plugin version. update_option('socialcountplus_version', Social_Count_Plus::VERSION); // Reset the counters. Social_Count_Plus_Generator::reset_count(); } }
/** * Widget view. * * @return string */ public static function get_view() { wp_enqueue_style('social-count-plus'); $settings = get_option('socialcountplus_settings'); $design = get_option('socialcountplus_design'); $count = Social_Count_Plus_Generator::get_count(); $color = isset($design['text_color']) ? $design['text_color'] : '#333333'; $icons = isset($design['icons']) ? explode(',', $design['icons']) : array(); // Sets view design. $style = ''; switch ($design['models']) { case 1: $style = 'default vertical'; break; case 2: $style = 'circle'; break; case 3: $style = 'circle vertical'; break; case 4: $style = 'flat'; break; case 5: $style = 'flat vertical'; break; case 6: $style = 'custom'; break; case 7: $style = 'custom vertical'; break; default: $style = 'default'; break; } $html = '<div class="social-count-plus">'; $html .= '<ul class="' . $style . '">'; foreach ($icons as $icon) { $method = 'get_' . $icon . '_counter'; $html .= self::$method($settings, $count[$icon], $color); } $html .= '</ul>'; $html .= '</div>'; return $html; }
/** * All counters function. * * @return array All counts. */ function get_scp_all() { $count = Social_Count_Plus_Generator::get_count(); return $count; }
/** * Comments counter function. * * @deprecated since 3.2.0 * * @return int Comments count. */ function get_scp_comments() { _deprecated_function('get_scp_comments', '3.2.0', 'get_scp_counter'); $count = Social_Count_Plus_Generator::get_count(); return $count['comments']; }