public function save_fields()
 {
     $model = new Setting();
     $model->color_primary = Utils_Helper::post(Setting::OPTION_COLOR_PRIMARY, false, 'esc_html');
     $model->color_secondary = Utils_Helper::post(Setting::OPTION_COLOR_SECONDARY, false, 'esc_html');
     $model->color_tertiary = Utils_Helper::post(Setting::OPTION_COLOR_TERTIARY, false, 'esc_html');
     $model->branding = Utils_Helper::post(Setting::OPTION_BRANDING, false, 'intval');
     $model->branding_height = Utils_Helper::post(Setting::OPTION_BRANDING_HEIGHT, false, 'intval');
 }
    /**
     * 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};
 }
Example #4
0
 public function get_branding_url($size = 'full')
 {
     return Utils_Helper::get_thumbnail_url($this->_get_property('branding'), $size);
 }
 /**
  * Enqueue scripts and stylesheets on admin
  *
  * @since 1.2
  * @param Null
  * @return Void
  */
 public function admin_scripts()
 {
     wp_enqueue_script(Setting::PREFIX . '-admin-scripts', Utils_Helper::plugin_url('javascripts/built.admin.js'), array('jquery'), Utils_Helper::filetime(Utils_Helper::file_path('javascripts/built.admin.js')), true);
     wp_enqueue_style(Setting::PREFIX . '-admin-style', Utils_Helper::plugin_url('stylesheets/admin.css'), array(), Utils_Helper::filetime(Utils_Helper::file_path('stylesheets/admin.css')));
 }
 /**
  * Get arguments for social url elements
  *
  * @since 1.0
  * @param Null
  * @return Array
  */
 private static function _get_arguments()
 {
     $title = Utils_Helper::get_title();
     $body_mail = Utils_Helper::body_mail();
     $arguments = array('title' => "\"{$title} \"", 'link' => Utils_Helper::get_permalink(), 'thumbnail' => Utils_Helper::get_image(), 'body_mail' => "\n\n{$title}\n\n{$body_mail}\n");
     return apply_filters(Init::PLUGIN_SLUG . 'arguments', $arguments);
 }
 /**
  * Create table sharing reports.
  *
  * @since 1.1
  * @global $wpdb
  * @param Null
  * @global $wpdb
  * @return Void
  */
 public function create_table()
 {
     global $wpdb;
     $charset = $wpdb->get_charset_collate();
     $table_name = $wpdb->prefix . Setting::TABLE_NAME;
     $sql = "\n\t\t\tCREATE TABLE IF NOT EXISTS {$table_name} (\n\t\t\t\tid         BIGINT(20) NOT NULL AUTO_INCREMENT,\n\t\t\t\tpost_id    BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\tpost_title TEXT       NOT NULL,\n\t\t\t\tfacebook   BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\ttwitter    BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\tgoogle     BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\tlinkedin   BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\tpinterest  BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\ttotal      BIGINT(20) UNSIGNED NOT NULL,\n\t\t\t\tPRIMARY KEY id ( id ),\n\t\t\t\tUNIQUE( post_id )\n\t\t\t)   {$charset};";
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     dbDelta($sql);
     Utils_Helper::add_update_option(Setting::TABLE_NAME . '_db_version');
 }
    /**
     * 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 
    }
 /**
  * Verify json requests
  *
  * @since 1.0
  * @param Integer $post_id
  * @param String $nonce
  * @return Boolean
  */
 private static function _verify_request($post_id, $nonce)
 {
     if (!$post_id) {
         Utils_Helper::error_server_json('reference_not_found');
         http_response_code(500);
         return true;
     }
     if (!wp_verify_nonce($nonce, self::AJAX_VERIFY_NONCE_COUNTER)) {
         Utils_Helper::error_server_json('nonce_not_found');
         http_response_code(500);
         return true;
     }
     return false;
 }
 /**
  * Create custom class from icons
  *
  * @since 1.0
  * @param Array $args
  * @return HTML
  */
 public static function buttons_share($atts = array())
 {
     $atts = array_map(array('JM\\Share_Buttons\\Utils_Helper', 'esc_class'), $atts);
     $args = array('class_first' => Utils_Helper::isset_set($atts, 'class_first'), 'class_second' => Utils_Helper::isset_set($atts, 'class_second'), 'class_link' => Utils_Helper::isset_set($atts, 'class_link'), 'class_icon' => Utils_Helper::isset_set($atts, 'class_icon'), 'layout' => Utils_Helper::isset_set($atts, 'layout'), 'elements' => array('remove_inside' => Utils_Helper::isset_set($atts, 'remove_inside'), 'remove_counter' => Utils_Helper::isset_set($atts, 'remove_counter')));
     return self::get_buttons($args);
 }
 /**
  * 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;
 }
Example #12
0
 /**
  * Get arguments for social url elements
  *
  * @since 1.0
  * @param Null
  * @return Array
  */
 private static function _get_arguments()
 {
     $title = Utils_Helper::get_title();
     $body_mail = Utils_Helper::body_mail();
     $arguments = array('title' => "\"{$title} \"", 'link' => Utils_Helper::get_permalink(), 'thumbnail' => Utils_Helper::get_image(), 'body_mail' => "\n\n{$title}\n\n{$body_mail}\n");
     return $arguments;
 }