| @@ -21,19 +21,19 @@ discard block | ||
| 21 | 21 | * Contructor | 
| 22 | 22 | */ | 
| 23 | 23 |  	public function __construct() { | 
| 24 | - add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 5 ); | |
| 25 | - add_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html' ), 10, 2 ); | |
| 26 | - add_shortcode( 'lsx_sharing_buttons', array( $this, 'sharing_buttons_shortcode' ) ); | |
| 24 | +		add_action('wp_enqueue_scripts', array($this, 'assets'), 5); | |
| 25 | +		add_filter('wp_kses_allowed_html', array($this, 'wp_kses_allowed_html'), 10, 2); | |
| 26 | +		add_shortcode('lsx_sharing_buttons', array($this, 'sharing_buttons_shortcode')); | |
| 27 | 27 | // Storefront (storefront_loop_post, storefront_single_post). | 
| 28 | - add_action( 'storefront_post_content_before', array( $this, 'sharing_buttons_template' ), 20 ); | |
| 28 | +		add_action('storefront_post_content_before', array($this, 'sharing_buttons_template'), 20); | |
| 29 | 29 | // WooCommerce. | 
| 30 | - add_action( 'woocommerce_share', array( $this, 'sharing_buttons_template' ) ); | |
| 30 | +		add_action('woocommerce_share', array($this, 'sharing_buttons_template')); | |
| 31 | 31 | |
| 32 | 32 | // General Post Types. | 
| 33 | - add_action( 'lsx_entry_after', array( $this, 'output_sharing' ) ); | |
| 33 | +		add_action('lsx_entry_after', array($this, 'output_sharing')); | |
| 34 | 34 | |
| 35 | 35 | // Tribe Events. | 
| 36 | - add_filter( 'tribe_events_ical_single_event_links', array( $this, 'output_event_sharing' ), 10, 1 ); | |
| 36 | +		add_filter('tribe_events_ical_single_event_links', array($this, 'output_event_sharing'), 10, 1); | |
| 37 | 37 | } | 
| 38 | 38 | |
| 39 | 39 | /** | 
| @@ -45,7 +45,7 @@ discard block | ||
| 45 | 45 | */ | 
| 46 | 46 |  	public static function get_instance() { | 
| 47 | 47 | // If the single instance hasn't been set, set it now. | 
| 48 | -		if ( null == self::$instance ) { | |
| 48 | +		if (null == self::$instance) { | |
| 49 | 49 | self::$instance = new self(); | 
| 50 | 50 | } | 
| 51 | 51 | return self::$instance; | 
| @@ -55,14 +55,14 @@ discard block | ||
| 55 | 55 | * Enques the assets. | 
| 56 | 56 | */ | 
| 57 | 57 |  	public function assets() { | 
| 58 | -		if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) { | |
| 58 | +		if (defined('WP_DEBUG') && true === WP_DEBUG) { | |
| 59 | 59 | $min = ''; | 
| 60 | 60 |  		} else { | 
| 61 | 61 | $min = '.min'; | 
| 62 | 62 | } | 
| 63 | 63 | /* Remove assets completely if all sharing options are off */ | 
| 64 | 64 | |
| 65 | -		if ( \lsx\sharing\includes\functions\is_disabled() ) { | |
| 65 | +		if (\lsx\sharing\includes\functions\is_disabled()) { | |
| 66 | 66 | return ''; | 
| 67 | 67 | } | 
| 68 | 68 | |
| @@ -70,67 +70,67 @@ discard block | ||
| 70 | 70 | $post_type = get_post_type(); | 
| 71 | 71 | |
| 72 | 72 | /* Only show the assets if the post type sharing option is on */ | 
| 73 | -		if ( ! \lsx\sharing\includes\functions\is_pt_disabled( $post_type ) ) { | |
| 73 | +		if ( ! \lsx\sharing\includes\functions\is_pt_disabled($post_type)) { | |
| 74 | 74 | |
| 75 | - wp_enqueue_script( 'lsx-sharing', LSX_SHARING_URL . 'assets/js/lsx-sharing' . $min . '.js', array( 'jquery' ), LSX_SHARING_VER, true ); | |
| 75 | +			wp_enqueue_script('lsx-sharing', LSX_SHARING_URL . 'assets/js/lsx-sharing' . $min . '.js', array('jquery'), LSX_SHARING_VER, true); | |
| 76 | 76 | |
| 77 | - $params = apply_filters( 'lsx_sharing_js_params', array( | |
| 78 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), | |
| 77 | +			$params = apply_filters('lsx_sharing_js_params', array( | |
| 78 | +				'ajax_url' => admin_url('admin-ajax.php'), | |
| 79 | 79 | )); | 
| 80 | 80 | |
| 81 | - wp_localize_script( 'lsx-sharing', 'lsx_sharing_params', $params ); | |
| 81 | +			wp_localize_script('lsx-sharing', 'lsx_sharing_params', $params); | |
| 82 | 82 | |
| 83 | - wp_enqueue_style( 'lsx-sharing', LSX_SHARING_URL . 'assets/css/lsx-sharing.css', array(), LSX_SHARING_VER ); | |
| 84 | - wp_style_add_data( 'lsx-sharing', 'rtl', 'replace' ); | |
| 83 | +			wp_enqueue_style('lsx-sharing', LSX_SHARING_URL . 'assets/css/lsx-sharing.css', array(), LSX_SHARING_VER); | |
| 84 | +			wp_style_add_data('lsx-sharing', 'rtl', 'replace'); | |
| 85 | 85 | } | 
| 86 | 86 | } | 
| 87 | 87 | |
| 88 | 88 | /** | 
| 89 | 89 | * Display/return sharing buttons. | 
| 90 | 90 | */ | 
| 91 | -	public function sharing_buttons( $buttons = array( 'facebook', 'twitter', 'pinterest' ), $echo = false, $post_id = false ) { | |
| 91 | +	public function sharing_buttons($buttons = array('facebook', 'twitter', 'pinterest'), $echo = false, $post_id = false) { | |
| 92 | 92 | $sharing_content = ''; | 
| 93 | 93 | |
| 94 | -		if ( ( is_preview() || is_admin() ) && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { | |
| 94 | +		if ((is_preview() || is_admin()) && ! (defined('DOING_AJAX') && DOING_AJAX)) { | |
| 95 | 95 | return ''; | 
| 96 | 96 | } | 
| 97 | 97 | |
| 98 | 98 | //Set our variables | 
| 99 | 99 | global $post; | 
| 100 | 100 | $share_post = $post; | 
| 101 | -		if ( false !== $post_id ) { | |
| 102 | - $share_post = get_post( $post_id ); | |
| 103 | - $post_type = get_post_type( $post_id ); | |
| 101 | +		if (false !== $post_id) { | |
| 102 | + $share_post = get_post($post_id); | |
| 103 | + $post_type = get_post_type($post_id); | |
| 104 | 104 |  		} else { | 
| 105 | 105 | $post_type = get_post_type(); | 
| 106 | 106 | } | 
| 107 | 107 | |
| 108 | -		if ( \lsx\sharing\includes\functions\is_disabled() || \lsx\sharing\includes\functions\is_pt_disabled( $post_type ) ) { | |
| 108 | +		if (\lsx\sharing\includes\functions\is_disabled() || \lsx\sharing\includes\functions\is_pt_disabled($post_type)) { | |
| 109 | 109 | return ''; | 
| 110 | 110 | } | 
| 111 | 111 | |
| 112 | -		if ( ( is_array( $buttons ) && count( $buttons ) > 0 ) ) { | |
| 112 | +		if ((is_array($buttons) && count($buttons) > 0)) { | |
| 113 | 113 | $sharing_content .= '<div class="lsx-sharing-content"><p>'; | 
| 114 | 114 | |
| 115 | - $sharing_text = \lsx\sharing\includes\functions\get_sharing_text( $post_type ); | |
| 116 | -			if ( '' !== $sharing_text ) { | |
| 115 | + $sharing_text = \lsx\sharing\includes\functions\get_sharing_text($post_type); | |
| 116 | +			if ('' !== $sharing_text) { | |
| 117 | 117 | $sharing_content .= '<span class="lsx-sharing-label">' . $sharing_text . '</span>'; | 
| 118 | 118 | } | 
| 119 | 119 | |
| 120 | -			foreach ( $buttons as $id => $button ) { | |
| 121 | - $button_obj = new \lsx\sharing\classes\frontend\Button( $button, $this->options, $post_type ); | |
| 120 | +			foreach ($buttons as $id => $button) { | |
| 121 | + $button_obj = new \lsx\sharing\classes\frontend\Button($button, $this->options, $post_type); | |
| 122 | 122 | |
| 123 | -				if ( ! empty( $button_obj ) ) { | |
| 124 | - $url = $button_obj->get_link( $share_post ); | |
| 123 | +				if ( ! empty($button_obj)) { | |
| 124 | + $url = $button_obj->get_link($share_post); | |
| 125 | 125 | |
| 126 | -					if ( ! empty( $url ) ) { | |
| 127 | -						if ( 'email' === $button ) { | |
| 128 | -							if ( ! isset( $this->options['display'] ) || empty( $this->options['display']['sharing_email_form_id'] ) ) { | |
| 126 | +					if ( ! empty($url)) { | |
| 127 | +						if ('email' === $button) { | |
| 128 | +							if ( ! isset($this->options['display']) || empty($this->options['display']['sharing_email_form_id'])) { | |
| 129 | 129 | continue; | 
| 130 | 130 | } | 
| 131 | - $sharing_content .= '<span class="lsx-sharing-button lsx-sharing-button-' . esc_attr( $button ) . '"><a href="#lsx-sharing-email" data-toggle="modal" data-link="' . esc_url( $url ) . '"><span class="fa" aria-hidden="true"></span></a></span>'; | |
| 131 | + $sharing_content .= '<span class="lsx-sharing-button lsx-sharing-button-' . esc_attr($button) . '"><a href="#lsx-sharing-email" data-toggle="modal" data-link="' . esc_url($url) . '"><span class="fa" aria-hidden="true"></span></a></span>'; | |
| 132 | 132 |  						} else { | 
| 133 | - $sharing_content .= '<span class="lsx-sharing-button lsx-sharing-button-' . esc_attr( $button ) . '"><a href="' . esc_url( $url ) . '" target="_blank" rel="noopener noreferrer"><span class="fa" aria-hidden="true"></span></a></span>'; | |
| 133 | + $sharing_content .= '<span class="lsx-sharing-button lsx-sharing-button-' . esc_attr($button) . '"><a href="' . esc_url($url) . '" target="_blank" rel="noopener noreferrer"><span class="fa" aria-hidden="true"></span></a></span>'; | |
| 134 | 134 | } | 
| 135 | 135 | } | 
| 136 | 136 | } | 
| @@ -138,8 +138,8 @@ discard block | ||
| 138 | 138 | $sharing_content .= '</p></div>'; | 
| 139 | 139 | } | 
| 140 | 140 | |
| 141 | -		if ( $echo ) { | |
| 142 | - echo wp_kses_post( $sharing_content ); | |
| 141 | +		if ($echo) { | |
| 142 | + echo wp_kses_post($sharing_content); | |
| 143 | 143 |  		} else { | 
| 144 | 144 | return $sharing_content; | 
| 145 | 145 | } | 
| @@ -148,20 +148,20 @@ discard block | ||
| 148 | 148 | /** | 
| 149 | 149 | * Sharing buttons shortcode. | 
| 150 | 150 | */ | 
| 151 | -	public function sharing_buttons_shortcode( $atts ) { | |
| 152 | - $atts = shortcode_atts( array( | |
| 151 | +	public function sharing_buttons_shortcode($atts) { | |
| 152 | + $atts = shortcode_atts(array( | |
| 153 | 153 | 'buttons' => '', | 
| 154 | - ), $atts, 'lsx_sharing_buttons' ); | |
| 154 | + ), $atts, 'lsx_sharing_buttons'); | |
| 155 | 155 | |
| 156 | -		if ( empty( $atts['buttons'] ) ) { | |
| 156 | +		if (empty($atts['buttons'])) { | |
| 157 | 157 | return ''; | 
| 158 | 158 | } | 
| 159 | 159 | |
| 160 | - $no_whitespaces = preg_replace( '/\s*,\s*/', ',', filter_var( $atts['buttons'], FILTER_SANITIZE_STRING ) ); | |
| 161 | - $buttons = explode( ',', $no_whitespaces ); | |
| 160 | +		$no_whitespaces = preg_replace('/\s*,\s*/', ',', filter_var($atts['buttons'], FILTER_SANITIZE_STRING)); | |
| 161 | +		$buttons        = explode(',', $no_whitespaces); | |
| 162 | 162 | |
| 163 | -		if ( is_array( $buttons ) && count( $buttons ) > 0 ) { | |
| 164 | - return $this->sharing_buttons( $buttons ); | |
| 163 | +		if (is_array($buttons) && count($buttons) > 0) { | |
| 164 | + return $this->sharing_buttons($buttons); | |
| 165 | 165 | } | 
| 166 | 166 | } | 
| 167 | 167 | |
| @@ -169,13 +169,13 @@ discard block | ||
| 169 | 169 | * Display buttons (template hook). | 
| 170 | 170 | */ | 
| 171 | 171 |  	public function sharing_buttons_template() { | 
| 172 | - echo wp_kses_post( $this->sharing_buttons() ); | |
| 172 | + echo wp_kses_post($this->sharing_buttons()); | |
| 173 | 173 | } | 
| 174 | 174 | |
| 175 | 175 | /** | 
| 176 | 176 | * Allow data params for Bootstrap modal. | 
| 177 | 177 | */ | 
| 178 | -	public function wp_kses_allowed_html( $allowedtags, $context ) { | |
| 178 | +	public function wp_kses_allowed_html($allowedtags, $context) { | |
| 179 | 179 | $allowedtags['a']['data-toggle'] = true; | 
| 180 | 180 | $allowedtags['a']['data-link'] = true; | 
| 181 | 181 | return $allowedtags; | 
| @@ -187,8 +187,8 @@ discard block | ||
| 187 | 187 | * @return void | 
| 188 | 188 | */ | 
| 189 | 189 |  	public function output_sharing() { | 
| 190 | -		if ( is_main_query() && is_single() && ! is_singular( array( 'post', 'page', 'product' ) ) ) { | |
| 191 | -			if ( \lsx\sharing\includes\functions\is_disabled() || \lsx\sharing\includes\functions\is_pt_disabled( get_post_type() ) ) { | |
| 190 | +		if (is_main_query() && is_single() && ! is_singular(array('post', 'page', 'product'))) { | |
| 191 | +			if (\lsx\sharing\includes\functions\is_disabled() || \lsx\sharing\includes\functions\is_pt_disabled(get_post_type())) { | |
| 192 | 192 | return ''; | 
| 193 | 193 | } | 
| 194 | 194 | ?> | 
| @@ -207,8 +207,8 @@ discard block | ||
| 207 | 207 | * @param string $ical_links | 
| 208 | 208 | * @return string | 
| 209 | 209 | */ | 
| 210 | -	public function output_event_sharing( $ical_links = '' ) { | |
| 211 | -		if ( \lsx\sharing\includes\functions\is_disabled() || \lsx\sharing\includes\functions\is_pt_disabled( get_post_type() ) ) { | |
| 210 | +	public function output_event_sharing($ical_links = '') { | |
| 211 | +		if (\lsx\sharing\includes\functions\is_disabled() || \lsx\sharing\includes\functions\is_pt_disabled(get_post_type())) { | |
| 212 | 212 | return ''; | 
| 213 | 213 |  		} else { | 
| 214 | 214 | $ical_links .= $this->sharing_buttons(); |