@@ -21,22 +21,22 @@ 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 | // Sensei Integration. |
39 | - add_action( 'sensei_pagination', array( $this, 'output_sharing' ), 20 ); |
|
39 | + add_action('sensei_pagination', array($this, 'output_sharing'), 20); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public static function get_instance() { |
50 | 50 | // If the single instance hasn't been set, set it now. |
51 | - if ( null == self::$instance ) { |
|
51 | + if (null == self::$instance) { |
|
52 | 52 | self::$instance = new self(); |
53 | 53 | } |
54 | 54 | return self::$instance; |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | * Enques the assets. |
59 | 59 | */ |
60 | 60 | public function assets() { |
61 | - if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) { |
|
61 | + if (defined('WP_DEBUG') && true === WP_DEBUG) { |
|
62 | 62 | $min = ''; |
63 | 63 | } else { |
64 | 64 | $min = '.min'; |
65 | 65 | } |
66 | 66 | /* Remove assets completely if all sharing options are off */ |
67 | 67 | |
68 | - if ( \lsx\sharing\includes\functions\is_disabled() ) { |
|
68 | + if (\lsx\sharing\includes\functions\is_disabled()) { |
|
69 | 69 | return ''; |
70 | 70 | } |
71 | 71 | |
@@ -73,71 +73,71 @@ discard block |
||
73 | 73 | $post_type = get_post_type(); |
74 | 74 | |
75 | 75 | /* Only show the assets if the post type sharing option is on */ |
76 | - if ( ! \lsx\sharing\includes\functions\is_pt_disabled( $post_type ) ) { |
|
76 | + if ( ! \lsx\sharing\includes\functions\is_pt_disabled($post_type)) { |
|
77 | 77 | |
78 | - wp_enqueue_script( 'lsx-sharing', LSX_SHARING_URL . 'assets/js/lsx-sharing' . $min . '.js', array( 'jquery' ), LSX_SHARING_VER, true ); |
|
78 | + wp_enqueue_script('lsx-sharing', LSX_SHARING_URL . 'assets/js/lsx-sharing' . $min . '.js', array('jquery'), LSX_SHARING_VER, true); |
|
79 | 79 | |
80 | - $params = apply_filters( 'lsx_sharing_js_params', array( |
|
81 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
80 | + $params = apply_filters('lsx_sharing_js_params', array( |
|
81 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
82 | 82 | )); |
83 | 83 | |
84 | - wp_localize_script( 'lsx-sharing', 'lsx_sharing_params', $params ); |
|
84 | + wp_localize_script('lsx-sharing', 'lsx_sharing_params', $params); |
|
85 | 85 | |
86 | - wp_enqueue_style( 'lsx-sharing', LSX_SHARING_URL . 'assets/css/lsx-sharing.css', array(), LSX_SHARING_VER ); |
|
87 | - wp_style_add_data( 'lsx-sharing', 'rtl', 'replace' ); |
|
86 | + wp_enqueue_style('lsx-sharing', LSX_SHARING_URL . 'assets/css/lsx-sharing.css', array(), LSX_SHARING_VER); |
|
87 | + wp_style_add_data('lsx-sharing', 'rtl', 'replace'); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
92 | 92 | * Display/return sharing buttons. |
93 | 93 | */ |
94 | - public function sharing_buttons( $buttons = array( 'facebook', 'twitter', 'pinterest' ), $echo = false, $post_id = false ) { |
|
94 | + public function sharing_buttons($buttons = array('facebook', 'twitter', 'pinterest'), $echo = false, $post_id = false) { |
|
95 | 95 | $sharing_content = ''; |
96 | 96 | |
97 | - if ( ( is_preview() || is_admin() ) && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
|
97 | + if ((is_preview() || is_admin()) && ! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
98 | 98 | return ''; |
99 | 99 | } |
100 | 100 | |
101 | - if ( empty( $this->options ) ) { |
|
101 | + if (empty($this->options)) { |
|
102 | 102 | $this->options = array(); |
103 | 103 | } |
104 | 104 | |
105 | 105 | //Set our variables |
106 | 106 | global $post; |
107 | 107 | $share_post = $post; |
108 | - if ( false !== $post_id ) { |
|
109 | - $share_post = get_post( $post_id ); |
|
110 | - $post_type = get_post_type( $post_id ); |
|
108 | + if (false !== $post_id) { |
|
109 | + $share_post = get_post($post_id); |
|
110 | + $post_type = get_post_type($post_id); |
|
111 | 111 | } else { |
112 | 112 | $post_type = get_post_type(); |
113 | 113 | } |
114 | 114 | |
115 | - if ( \lsx\sharing\includes\functions\is_disabled() || \lsx\sharing\includes\functions\is_pt_disabled( $post_type ) ) { |
|
115 | + if (\lsx\sharing\includes\functions\is_disabled() || \lsx\sharing\includes\functions\is_pt_disabled($post_type)) { |
|
116 | 116 | return ''; |
117 | 117 | } |
118 | 118 | |
119 | - if ( ( is_array( $buttons ) && count( $buttons ) > 0 ) ) { |
|
119 | + if ((is_array($buttons) && count($buttons) > 0)) { |
|
120 | 120 | $sharing_content .= '<div class="lsx-sharing-content"><p>'; |
121 | 121 | |
122 | - $sharing_text = \lsx\sharing\includes\functions\get_sharing_text( $post_type ); |
|
123 | - if ( '' !== $sharing_text ) { |
|
122 | + $sharing_text = \lsx\sharing\includes\functions\get_sharing_text($post_type); |
|
123 | + if ('' !== $sharing_text) { |
|
124 | 124 | $sharing_content .= '<span class="lsx-sharing-label">' . $sharing_text . '</span>'; |
125 | 125 | } |
126 | 126 | |
127 | - foreach ( $buttons as $id => $button ) { |
|
128 | - $button_obj = new \lsx\sharing\classes\frontend\Button( $button, $this->options, $post_type ); |
|
127 | + foreach ($buttons as $id => $button) { |
|
128 | + $button_obj = new \lsx\sharing\classes\frontend\Button($button, $this->options, $post_type); |
|
129 | 129 | |
130 | - if ( ! empty( $button_obj ) ) { |
|
131 | - $url = $button_obj->get_link( $share_post ); |
|
130 | + if ( ! empty($button_obj)) { |
|
131 | + $url = $button_obj->get_link($share_post); |
|
132 | 132 | |
133 | - if ( ! empty( $url ) ) { |
|
134 | - if ( 'email' === $button ) { |
|
135 | - if ( ! isset( $this->options['display'] ) || empty( $this->options['display']['sharing_email_form_id'] ) ) { |
|
133 | + if ( ! empty($url)) { |
|
134 | + if ('email' === $button) { |
|
135 | + if ( ! isset($this->options['display']) || empty($this->options['display']['sharing_email_form_id'])) { |
|
136 | 136 | continue; |
137 | 137 | } |
138 | - $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>'; |
|
138 | + $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>'; |
|
139 | 139 | } else { |
140 | - $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>'; |
|
140 | + $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>'; |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | } |
@@ -145,8 +145,8 @@ discard block |
||
145 | 145 | $sharing_content .= '</p></div>'; |
146 | 146 | } |
147 | 147 | |
148 | - if ( $echo ) { |
|
149 | - echo wp_kses_post( $sharing_content ); |
|
148 | + if ($echo) { |
|
149 | + echo wp_kses_post($sharing_content); |
|
150 | 150 | } else { |
151 | 151 | return $sharing_content; |
152 | 152 | } |
@@ -155,20 +155,20 @@ discard block |
||
155 | 155 | /** |
156 | 156 | * Sharing buttons shortcode. |
157 | 157 | */ |
158 | - public function sharing_buttons_shortcode( $atts ) { |
|
159 | - $atts = shortcode_atts( array( |
|
158 | + public function sharing_buttons_shortcode($atts) { |
|
159 | + $atts = shortcode_atts(array( |
|
160 | 160 | 'buttons' => '', |
161 | - ), $atts, 'lsx_sharing_buttons' ); |
|
161 | + ), $atts, 'lsx_sharing_buttons'); |
|
162 | 162 | |
163 | - if ( empty( $atts['buttons'] ) ) { |
|
163 | + if (empty($atts['buttons'])) { |
|
164 | 164 | return ''; |
165 | 165 | } |
166 | 166 | |
167 | - $no_whitespaces = preg_replace( '/\s*,\s*/', ',', filter_var( $atts['buttons'], FILTER_SANITIZE_STRING ) ); |
|
168 | - $buttons = explode( ',', $no_whitespaces ); |
|
167 | + $no_whitespaces = preg_replace('/\s*,\s*/', ',', filter_var($atts['buttons'], FILTER_SANITIZE_STRING)); |
|
168 | + $buttons = explode(',', $no_whitespaces); |
|
169 | 169 | |
170 | - if ( is_array( $buttons ) && count( $buttons ) > 0 ) { |
|
171 | - return $this->sharing_buttons( $buttons ); |
|
170 | + if (is_array($buttons) && count($buttons) > 0) { |
|
171 | + return $this->sharing_buttons($buttons); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
@@ -176,13 +176,13 @@ discard block |
||
176 | 176 | * Display buttons (template hook). |
177 | 177 | */ |
178 | 178 | public function sharing_buttons_template() { |
179 | - echo wp_kses_post( $this->sharing_buttons() ); |
|
179 | + echo wp_kses_post($this->sharing_buttons()); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
183 | 183 | * Allow data params for Bootstrap modal. |
184 | 184 | */ |
185 | - public function wp_kses_allowed_html( $allowedtags, $context ) { |
|
185 | + public function wp_kses_allowed_html($allowedtags, $context) { |
|
186 | 186 | $allowedtags['a']['data-toggle'] = true; |
187 | 187 | $allowedtags['a']['data-link'] = true; |
188 | 188 | return $allowedtags; |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | * @return void |
195 | 195 | */ |
196 | 196 | public function output_sharing() { |
197 | - if ( is_main_query() && is_single() && ! is_singular( array( 'post', 'page', 'product' ) ) ) { |
|
197 | + if (is_main_query() && is_single() && ! is_singular(array('post', 'page', 'product'))) { |
|
198 | 198 | |
199 | - if ( \lsx\sharing\includes\functions\is_disabled() || \lsx\sharing\includes\functions\is_pt_disabled( get_post_type() ) || in_array( get_post_type(), \lsx\sharing\includes\functions\get_restricted_post_types() ) || in_array( get_post_type(), \lsx\sharing\includes\functions\get_to_post_types() ) || in_array( get_post_type(), \lsx\sharing\includes\functions\get_hp_post_types() ) ) { |
|
199 | + if (\lsx\sharing\includes\functions\is_disabled() || \lsx\sharing\includes\functions\is_pt_disabled(get_post_type()) || in_array(get_post_type(), \lsx\sharing\includes\functions\get_restricted_post_types()) || in_array(get_post_type(), \lsx\sharing\includes\functions\get_to_post_types()) || in_array(get_post_type(), \lsx\sharing\includes\functions\get_hp_post_types())) { |
|
200 | 200 | return ''; |
201 | 201 | } |
202 | 202 | ?> |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | * @param string $ical_links |
216 | 216 | * @return string |
217 | 217 | */ |
218 | - public function output_event_sharing( $ical_links = '' ) { |
|
219 | - if ( \lsx\sharing\includes\functions\is_disabled() || \lsx\sharing\includes\functions\is_pt_disabled( get_post_type() ) ) { |
|
218 | + public function output_event_sharing($ical_links = '') { |
|
219 | + if (\lsx\sharing\includes\functions\is_disabled() || \lsx\sharing\includes\functions\is_pt_disabled(get_post_type())) { |
|
220 | 220 | return ''; |
221 | 221 | } else { |
222 | 222 | $ical_links .= $this->sharing_buttons(); |