/** * Enqueue scripts and styles * * @since 1.0 * @param Null * @return Void */ public function scripts() { if ('on' !== Utils_Helper::option('disable_js')) { wp_enqueue_script(Setting::PREFIX . '-scripts', Utils_Helper::plugin_url('javascripts/built.front.js'), array('jquery'), Utils_Helper::filetime(Utils_Helper::file_path('javascripts/built.front.js')), true); wp_localize_script(Setting::PREFIX . '-scripts', 'PluginGlobalVars', array('urlAjax' => admin_url('admin-ajax.php'))); } if ('on' !== Utils_Helper::option('disable_css')) { wp_enqueue_style(Setting::PREFIX . '-style', Utils_Helper::plugin_url('stylesheets/style.css'), array(), Utils_Helper::filetime(Utils_Helper::file_path('stylesheets/style.css'))); } }
/** * Display page sharing report * * @since 1.3 * @param Object $list_table * @return void */ public static function render_sharing_report($list_table) { $time_cache = Utils_Helper::option('report_cache_time', 10, 'intval'); $list_table->prepare_items(); ?> <div class="wrap"> <h2><?php _e('Social Sharing Buttons', Init::PLUGIN_SLUG); ?> </h2> <p class="description"><?php _e('Add the sharing buttons automatically.', Init::PLUGIN_SLUG); ?> </p> <span class="<?php echo Setting::PREFIX; ?> -settings-title"> <span class="description information-cache"> <?php printf(__('This report has a cache of %d minute', Init::PLUGIN_SLUG), $time_cache); ?> (s) </span> </span> <div class="<?php echo Setting::PREFIX; ?> -settings-wrap"> <?php $list_table->display(); ?> </div> </div> <?php }
/** * Use in __get() magic method to retrieve the value of the attribute * on demand. If the attribute is unset get his value before. * * @since 1.0 * @param string $prop_name The attribute name * @return mixed String/Integer The value of the attribute */ private function _get_property($prop_name) { switch ($prop_name) { case 'full_options': if (!isset($this->full_options)) { $this->full_options = $this->get_options(); } break; case 'single': if (!isset($this->single)) { $this->single = Utils_Helper::option('single'); } break; case 'before': if (!isset($this->before)) { $this->before = Utils_Helper::option('before'); } break; case 'after': if (!isset($this->after)) { $this->after = Utils_Helper::option('after'); } break; case 'pages': if (!isset($this->pages)) { $this->pages = Utils_Helper::option('pages'); } break; case 'home': if (!isset($this->home)) { $this->home = Utils_Helper::option('home'); } break; case 'class': if (!isset($this->class)) { $this->class = Utils_Helper::option('class'); } break; case 'printer': if (!isset($this->printer)) { $this->printer = Utils_Helper::option('printer'); } break; case 'google_plus': if (!isset($this->google_plus)) { $this->google_plus = Utils_Helper::option('google-plus'); } break; case 'pinterest': if (!isset($this->pinterest)) { $this->pinterest = Utils_Helper::option('pinterest'); } break; case 'linkedin': if (!isset($this->linkedin)) { $this->linkedin = Utils_Helper::option('linkedin'); } break; case 'facebook': if (!isset($this->facebook)) { $this->facebook = Utils_Helper::option('facebook'); } break; case 'whatsapp': if (!isset($this->whatsapp)) { $this->whatsapp = Utils_Helper::option('whatsapp'); } break; case 'twitter': if (!isset($this->twitter)) { $this->twitter = Utils_Helper::option('twitter'); } break; case 'tumblr': if (!isset($this->tumblr)) { $this->tumblr = Utils_Helper::option('tumblr'); } break; case 'email': if (!isset($this->email)) { $this->email = Utils_Helper::option('email'); } break; case 'disable_css': if (!isset($this->disable_css)) { $this->disable_css = Utils_Helper::option('disable_css'); } break; case 'disable_js': if (!isset($this->disable_js)) { $this->disable_js = Utils_Helper::option('disable_js'); } break; case 'layout': if (!isset($this->layout)) { $this->layout = Utils_Helper::option('layout', 'default', 'esc_html'); } break; case 'twitter_username': if (!isset($this->twitter_username)) { $this->twitter_username = Utils_Helper::option('twitter_via'); } break; case 'tracking': if (!isset($this->tracking)) { $this->tracking = Utils_Helper::option('tracking', '?utm_source=share_button&utm_medium=social_media&utm_campaign=social_share'); } break; case 'report_cache_time': if (!isset($this->report_cache_time)) { $this->report_cache_time = Utils_Helper::option('report_cache_time', 10, 'intval'); } break; case 'social_media': if (!isset($this->social_media)) { $this->social_media = get_option(self::PREFIX_UNDERSCORE . '_social_media'); } break; case 'remove_count': if (!isset($this->remove_count)) { $this->remove_count = Utils_Helper::option('remove_count', 0, 'intval'); } break; case 'remove_inside': if (!isset($this->remove_inside)) { $this->remove_inside = Utils_Helper::option('remove_inside', 0, 'intval'); } break; case 'position_fixed': if (!isset($this->position_fixed)) { $this->position_fixed = Utils_Helper::option('position_fixed'); } break; case 'fixed': if (!isset($this->fixed)) { $this->fixed = Utils_Helper::option('fixed'); } break; default: return false; break; } return $this->{$prop_name}; }
public function __construct() { $this->cache_time = Utils_Helper::option('report_cache_time', 10, 'intval'); add_action('admin_menu', array(&$this, 'menu')); parent::__construct(array('singular' => 'social-share-report', 'plural' => 'social-sharing-reports', 'screen' => 'interval-list', 'ajax' => false)); }
/** * Encode all items from data services * * @since 1.2 * @param Null * @return Object */ private static function _get_elements_encode() { $arguments = self::_get_arguments(); $tracking = Utils_Helper::option('tracking'); $tracking = Utils_Helper::html_decode($tracking); $elements = self::_set_elements(rawurlencode($arguments['title']), rawurlencode($arguments['link']), rawurlencode($tracking), rawurlencode($arguments['thumbnail']), rawurlencode($arguments['body_mail']), rawurlencode('➜ '), Utils_Helper::option('twitter_via')); return apply_filters(Init::PLUGIN_SLUG . 'elements-econded', $elements); }
/** * Display page setting * * @since 1.2 * @param Null * @return Void Display page */ public static function render_settings_page() { $model = new Setting(); $prefix = Setting::PREFIX; $prefix_underscore = Setting::PREFIX_UNDERSCORE; $option_name = "{$prefix_underscore}_settings"; $option_social_media = "{$prefix_underscore}_social_media"; ?> <div class="wrap" data-component="<?php echo $prefix; ?> "> <h2><?php _e('Social Sharing Buttons', Init::PLUGIN_SLUG); ?> </h2> <p class="description"><?php _e('Add the sharing buttons automatically.', Init::PLUGIN_SLUG); ?> </p> <span class="<?php echo "{$prefix}-title"; ?> "><?php _e('Settings', Init::PLUGIN_SLUG); ?> </span> <div class="<?php echo "{$prefix}-wrap"; ?> "> <form action="options.php" method="post"> <table class="form-table <?php echo "{$prefix}-table"; ?> " data-table="configurations"> <tbody> <tr class="<?php echo $prefix; ?> -items-available"> <th scope="row"> <label><?php _e('Places available', Init::PLUGIN_SLUG); ?> </label> </th> <td> <input id="<?php echo $prefix; ?> -single" type="checkbox" value="on" name="<?php echo "{$option_name}[single]"; ?> " <?php checked('on', $model->single); ?> > <label for="<?php echo $prefix; ?> -single"> <span><?php _e('Single', Init::PLUGIN_SLUG); ?> </span> </label> </td> <td> <input id="<?php echo $prefix; ?> -pages" type="checkbox" value="on" name="<?php echo "{$option_name}[pages]"; ?> " <?php checked('on', $model->pages); ?> > <label for="<?php echo $prefix; ?> -pages"> <span><?php _e('Pages', Init::PLUGIN_SLUG); ?> </span> </label> </td> <td> <input id="<?php echo $prefix; ?> -home" type="checkbox" value="on" name="<?php echo "{$option_name}[home]"; ?> " <?php checked('on', $model->home); ?> > <label for="<?php echo $prefix; ?> -home"> <span><?php _e('Page home', Init::PLUGIN_SLUG); ?> </span> </label> </td> <td> <input id="<?php echo $prefix; ?> -before" type="checkbox" value="on" name="<?php echo "{$option_name}[before]"; ?> " <?php checked('on', $model->before); ?> > <label for="<?php echo $prefix; ?> -before"> <span><?php _e('Before content', Init::PLUGIN_SLUG); ?> </span> </label> </td> <td> <input id="<?php echo $prefix; ?> -after" type="checkbox" value="on" name="<?php echo "{$option_name}[after]"; ?> " <?php checked('on', $model->after); ?> > <label for="<?php echo $prefix; ?> -after"> <span><?php _e('After content', Init::PLUGIN_SLUG); ?> </span> </label> </td> </tr> <tr class="<?php echo $prefix; ?> -social-networks"> <th scope="row"> <label for="social-media"><?php _e('Social networks available', Init::PLUGIN_SLUG); ?> </label> </th> <?php foreach (Core::social_media_objects() as $key => $social) { $content = '<td>'; $content .= sprintf("<input id=\"%s\" type=\"checkbox\" name=\"{$option_social_media}[%s]\" value=\"%s\" %s>", $social->class, $social->element, $social->element, checked($social->element, Utils_Helper::option($social->element), false)); $content .= sprintf('<label for="%s" class="%s"></label>', $social->class, "{$prefix}-icon {$social->class}-icon"); $content .= '</td>'; echo $content; } ?> </tr> <tr> <th scope="row"> <label for="<?php echo $prefix; ?> -class"> <?php _e('Custom class', Init::PLUGIN_SLUG); ?> </label> </th> <td> <input id="<?php echo $prefix; ?> -class" class="large-text" type="text" placeholder="<?php _e('Custom class for primary div', Init::PLUGIN_SLUG); ?> " name="<?php echo "{$option_name}[class]"; ?> " value="<?php echo $model->class; ?> "> </td> </tr> <tr class="<?php echo $prefix; ?> -layout-options"> <th scope="row"> <?php _e('Layout options', Init::PLUGIN_SLUG); ?> <p class="description"> <?php _e('All layout supports responsive', Init::PLUGIN_SLUG); ?> </p> </th> <td> <input id="<?php echo $prefix; ?> -default" type="radio" name="<?php echo "{$option_name}[layout]"; ?> " value="default" <?php checked('default', $model->layout); ?> > <label for="<?php echo $prefix; ?> -default"> <span><?php _e('Default', Init::PLUGIN_SLUG); ?> </span> </label> </td> <td> <input id="<?php echo $prefix; ?> -buttons" type="radio" name="<?php echo "{$option_name}[layout]"; ?> " value="buttons" <?php checked('buttons', $model->layout); ?> > <label for="<?php echo $prefix; ?> -buttons"> <span><?php _e('Button', Init::PLUGIN_SLUG); ?> </span> </label> </td> <td> <input id="<?php echo $prefix; ?> -rounded" type="radio" name="<?php echo "{$option_name}[layout]"; ?> " value="rounded" <?php checked('rounded', $model->layout); ?> > <label for="<?php echo $prefix; ?> -rounded"> <span><?php _e('Rounded', Init::PLUGIN_SLUG); ?> </span> </label> </td> <td> <input id="<?php echo $prefix; ?> -square" type="radio" name="<?php echo "{$option_name}[layout]"; ?> " value="square" <?php checked('square', $model->layout); ?> > <label for="<?php echo $prefix; ?> -square"> <span><?php _e('Square', Init::PLUGIN_SLUG); ?> </span> </label> </td> <td> <input id="<?php echo $prefix; ?> -square-plus" type="radio" name="<?php echo "{$option_name}[layout]"; ?> " value="square-plus" <?php checked('square-plus', $model->layout); ?> > <label for="<?php echo $prefix; ?> -square-plus"> <span><?php _e('Square plus', Init::PLUGIN_SLUG); ?> </span> </label> </td> </tr> <tr class="<?php echo $prefix; ?> -position-fixed"> <th scope="row"> <?php _e('Position fixed', Init::PLUGIN_SLUG); ?> </th> <td> <input id="<?php echo $prefix; ?> -fixed-left" type="checkbox" name="<?php echo "{$option_name}[position_fixed]"; ?> " value="fixed-left" <?php checked('fixed-left', $model->position_fixed); ?> > <label for="<?php echo $prefix; ?> -fixed-left"> <span><?php _e('Fixed left', Init::PLUGIN_SLUG); ?> </span> </label> </td> </tr> </tbody> </table> <?php settings_fields("{$option_name}_group"); submit_button(__('Save Changes', Init::PLUGIN_SLUG)); ?> </form> </div> </div> <?php }
/** * Verfy type and return links from icons * * @since 1.0 * @param String $popup * @param String $element_link * @return String */ private static function _link_type($popup, $element_link) { $attr_link = "data-attr-url=\"{$element_link}\""; if ('' === $popup || 'on' === Utils_Helper::option('disable_js')) { $attr_link = "href=\"{$element_link}\" target=\"_blank\""; } return apply_filters(Init::PLUGIN_SLUG . 'attr-link', $attr_link); }
/** * make sure is activated the sharing buttons in home * * @since 1.0 * @param Null * @return Boolean */ protected function _is_home() { if ((is_home() || is_front_page()) && Utils_Helper::option('home') === 'on') { return true; } return false; }
/** * Verfy type and return links from icons * * @since 1.0 * @param String $popup * @param String $element_link * @return String */ private static function _link_type($popup, $element_link) { $attr_link = "data-attr-url=\"{$element_link}\""; if ('' === $popup || 'on' === Utils_Helper::option('disable_js')) { $attr_link = "href=\"{$element_link}\" target=\"_blank\""; } return $attr_link; }
/** * Encode all items from data services * * @since 1.2 * @param Null * @return Object */ private static function _get_elements_encode() { $arguments = self::_get_arguments(); $tracking = Utils_Helper::option('tracking'); $tracking = Utils_Helper::html_decode($tracking); $elements = self::_set_elements(rawurlencode($arguments['title']), rawurlencode($arguments['link']), rawurlencode($tracking), rawurlencode($arguments['thumbnail']), rawurlencode($arguments['body_mail']), rawurlencode('➜ '), Utils_Helper::option('twitter_via')); return $elements; }