Changeset 1809716
- Timestamp:
- 01/26/2018 01:00:17 AM (8 years ago)
- Location:
- local-like-and-share/trunk
- Files:
-
- 1 added
- 8 edited
-
README.txt (modified) (3 diffs)
-
admin/class-local-like-and-share-admin.php (modified) (1 diff)
-
admin/views/local-like-and-share-admin-display-options.php (modified) (1 diff)
-
includes/class-local-like-and-share.php (modified) (1 diff)
-
languages/local-like-and-share.pot (modified) (3 diffs)
-
public/class-local-like-and-share-public.php (modified) (20 diffs)
-
public/css/local-like-and-share-shortcode.css (added)
-
public/js/local-like-and-share-public.js (modified) (1 diff)
-
public/js/local-like-and-share-public.min.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
local-like-and-share/trunk/README.txt
r1527830 r1809716 4 4 Tags: like, share, local, self-hosted, standalone, track like, track share 5 5 Requires at least: 4.3 6 Tested up to: 4.6 6 Tested up to: 4.9 7 Requires PHP: 5.6 7 8 Stable tag: 1.0.6 8 9 License: GPLv2 or later … … 44 45 * No shares found 45 46 47 * Versatile shortcode functionality: 48 * Generate like button directly in content 49 * Generate share button directly in content 50 * Usable in posts and on pages 51 46 52 * Configurable widget labels/input field placeholders: 47 53 * Show like section? … … 105 111 = Why isn't Local Like And Share translated into my language? = 106 112 107 It is because no one who speaks your language has translated this plugin yet. If you'd like to do so, you'll find the current local-like-and-share.pot file in the local-like-and-share/languages directory. [Please contact me](https://devonostendorf.com) with any translation files you create - thanks much!113 It is because no one who speaks your language has translated this plugin yet. If you'd like to do so, you'll find the current local-like-and-share.pot file in the local-like-and-share/languages directory. [Please contact me](https://devonostendorf.com) with any translation files you create; I will help you get set up as a Project Translation Editor (PTE) with the WordPress.org [Polyglots team](https://make.wordpress.org/polyglots/) to create a language pack for Local Like And Share - thanks much! 108 114 109 115 = Why build another like and share plugin? = 110 116 111 This was a somewhat spontaneous project; I wanted to add an easy-to-set-up way to allow likes and shares without requiring the user to sign into some other service. And lots of people choose not to use Facebook or Twitter. If you do, there are plenty of other plugins available. There are also other existing plugins that provide similar functionality but require you to maintain an account on their server(s) to access statistics. My aim was to provide a simple, self-contained, and locally-hosted tool where your stats stay with you (in the same way that the excellent [ Piwik](http://piwik.org) does for analytics). All while being independent from and unaffected by the whims of outside organizations that may change things without your knowledge or permission.117 This was a somewhat spontaneous project; I wanted to add an easy-to-set-up way to allow likes and shares without requiring the user to sign into some other service. And lots of people choose not to use Facebook or Twitter. If you do, there are plenty of other plugins available. There are also other existing plugins that provide similar functionality but require you to maintain an account on their server(s) to access statistics. My aim was to provide a simple, self-contained, and locally-hosted tool where your stats stay with you (in the same way that the excellent [Matomo](https://matomo.org) does for analytics). All while being independent from and unaffected by the whims of outside organizations that may change things without your knowledge or permission. 112 118 113 119 = How do I reset like or share counts? = 114 120 115 121 Go to the View Statistics page (Local Like And Share >> View Statistics), select the "All-time" tab, and press either the "Reset all like counts" or "Reset all share counts" button. This will reset ALL of your likes or shares (depending on which button you press). You will be presented with an "Undo" link immediately after having pressed a delete button. If you pressed a delete button by accident, or change your mind about deleting your counts, you must click the undo link IMMEDIATELY; your action CANNOT be reversed later. 122 123 = How do I use the shortcodes? = 124 125 1. Go to Settings >> Local Like And Share and make sure the settings in the Common Settings, Like Settings, and Share Settings sections are populated to your liking 126 <br /><br /> 127 128 **Note**: "Button(s) position on post", "Show on post index pages", and "Show on individual post" are not relevant to the shortcodes. 129 <br /><br /> 130 131 2. Add `[llas_like]` or `[llas_share]` to a post or page 132 <br /><br /> 133 134 3. If you use either shortcode more than once in a post or on a page, you MUST specify a unique value for the `id` attribute 135 136 Here is an example, passing the id attribute: 137 138 Somewhere in the middle of a post, we drop a like button. 139 <pre>[llas_like id="1"]</pre> 140 It is fine to reuse the same id for a share button. 141 <pre>[llas_share id="1"]</pre> 142 But we need to make the like button ids unique and here is a second one. 143 <pre>[llas_like id="2"]</pre> 144 And the second share button id must also be unique (among share buttons). 145 <pre>[llas_share id="2"]</pre> 146 That's all there is to it! 116 147 117 148 == Screenshots == -
local-like-and-share/trunk/admin/class-local-like-and-share-admin.php
r1499267 r1809716 263 263 ,'local-like-and-share-menu' 264 264 ,null 265 ,' '265 ,'dashicons-heart' 266 266 ,$local_like_and_share_options_arr['admin_menu_position'] 267 267 ); -
local-like-and-share/trunk/admin/views/local-like-and-share-admin-display-options.php
r1500010 r1809716 216 216 <tr valign="top"> 217 217 <th scope="row"> 218 <?php esc_html_e( 'Show on individual post ?:', 'local-like-and-share' ); ?>218 <?php esc_html_e( 'Show on individual post:', 'local-like-and-share' ); ?> 219 219 </th> 220 220 <td> -
local-like-and-share/trunk/includes/class-local-like-and-share.php
r1527830 r1809716 221 221 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); 222 222 223 // Register Like and Share shortcodes 224 $this->loader->add_action( 'init', $plugin_public, 'register_shortcodes' ); 225 223 226 // Display Like and Share buttons on posts 224 227 $this->loader->add_filter( 'the_content', $plugin_public, 'add_like_and_share_buttons_to_content' ); 225 228 226 229 // Like button functionality 227 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'l ike_button_clicked_enqueue' );230 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'localize_like_button_handler_script' ); 228 231 $this->loader->add_action( 'wp_ajax_like_button_clicked', $plugin_public, 'like_button_clicked_ajax_handler' ); 229 232 $this->loader->add_action( 'wp_ajax_nopriv_like_button_clicked', $plugin_public, 'like_button_clicked_ajax_handler' ); 230 233 231 234 // Share button functionality 232 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, ' share_button_clicked_enqueue' );235 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'localize_share_button_handler_script' ); 233 236 $this->loader->add_action( 'wp_ajax_share_button_clicked', $plugin_public, 'share_button_clicked_ajax_handler' ); 234 237 $this->loader->add_action( 'wp_ajax_nopriv_share_button_clicked', $plugin_public, 'share_button_clicked_ajax_handler' ); -
local-like-and-share/trunk/languages/local-like-and-share.pot
r1527830 r1809716 1 # Copyright (C) 201 6Local Like And Share1 # Copyright (C) 2018 Local Like And Share 2 2 # This file is distributed under the same license as the Local Like And Share package. 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Local Like And Share 1. 0.6\n"5 "Project-Id-Version: Local Like And Share 1.1.0\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/local-like-and-" 7 7 "share\n" 8 "POT-Creation-Date: 201 6-11-03 15:12:15+00:00\n"8 "POT-Creation-Date: 2018-01-25 21:43:49+00:00\n" 9 9 "MIME-Version: 1.0\n" 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "PO-Revision-Date: 201 6-MO-DA HO:MI+ZONE\n"12 "PO-Revision-Date: 2018-MO-DA HO:MI+ZONE\n" 13 13 "Last-Translator: Devon Ostendorf <[email protected]>\n" 14 14 "Language-Team: Devon Ostendorf <[email protected]>\n" … … 154 154 155 155 #: admin/views/local-like-and-share-admin-display-options.php:131 156 #: admin/views/local-like-and-share-admin-display-options.php:218 156 157 msgid "Show on individual post:" 157 158 msgstr "" … … 186 187 #: admin/views/local-like-and-share-admin-display-options.php:198 187 188 msgid "Share Settings" 188 msgstr ""189 190 #: admin/views/local-like-and-share-admin-display-options.php:218191 msgid "Show on individual post?:"192 189 msgstr "" 193 190 -
local-like-and-share/trunk/public/class-local-like-and-share-public.php
r1500010 r1809716 75 75 wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/local-like-and-share-public.min.css', array(), $this->version, 'all' ); 76 76 77 // Define all configurable styling here (everything else is in .css file) 78 79 $local_like_and_share_options_arr = get_option( 'local_like_and_share_settings' ); 80 81 $btn_hover_message_background_color = $local_like_and_share_options_arr['btn_hover_message_background_color']; 82 $btn_hover_message_text_color = $local_like_and_share_options_arr['btn_hover_message_text_color']; 83 84 $count_background_color = $local_like_and_share_options_arr['count_background_color']; 85 $count_outline_color = $local_like_and_share_options_arr['count_outline_color']; 86 $count_text_color = $local_like_and_share_options_arr['count_text_color']; 87 88 $like_button_color = $local_like_and_share_options_arr['like_btn_color']; 89 $like_button_hover_color = $local_like_and_share_options_arr['like_btn_hover_color']; 90 91 $share_button_color = $local_like_and_share_options_arr['share_btn_color']; 92 $share_button_hover_color = $local_like_and_share_options_arr['share_btn_hover_color']; 93 94 if ( 'left' == $local_like_and_share_options_arr['button_posn_horiz'] ) { 95 96 // Position button to left of post 97 $button_posn = 'float:left;margin:0px 10px 10px 0px'; 98 } 99 else { 100 101 // Position button to right of post 102 $button_posn = 'float:right;margin:0px 0px 10px 10px'; 103 } 104 105 $llas_buttons_style = ' 106 .llas-like-button-active { 107 ' . $button_posn . '; 108 } 109 .llas-like-button-active i { 110 cursor: pointer; 111 cursor: hand; 112 } 113 .llas-like-button-active a, 114 .llas-like-button-active a:visited, 115 .llas-like-button-active a:focus { 116 color: ' . esc_html( $like_button_color ) . '; 117 } 118 .llas-like-button-active a:hover { 119 color: ' . esc_html( $like_button_hover_color ) . '; 120 } 121 .llas-like-button-inactive { 122 ' . $button_posn . '; 123 } 124 .llas-like-button-inactive a, 125 .llas-like-button-inactive a:visited, 126 .llas-like-button-inactive a:focus, 127 .llas-like-button-inactive a:hover { 128 color: ' . esc_html( $like_button_color ) . '; 129 } 130 131 .llas-share-button-active { 132 ' . $button_posn . '; 133 } 134 .llas-share-button-active i { 135 cursor: pointer; 136 cursor: hand; 137 } 138 .llas-share-button-active a, 139 .llas-share-button-active a:visited, 140 .llas-share-button-active a:focus { 141 color: ' . esc_html( $share_button_color ) . '; 142 } 143 .llas-share-button-active a:hover { 144 color: ' . esc_html( $share_button_hover_color ) . '; 145 } 146 147 .llas-callout { 148 background-color: ' . esc_html( $count_background_color ) . '; 149 color: ' . esc_html( $count_text_color ) . '; 150 } 151 .llas-callout .llas-notch { 152 border-right: 5px solid ' . esc_html( $count_background_color ). '; 153 } 154 .llas-border-callout { 155 border: 1px solid ' . esc_html( $count_outline_color ) . '; 156 padding: 2px 9px; 157 } 158 .llas-border-callout .llas-border-notch { 159 border-right-color: ' . esc_html( $count_outline_color ) . '; 160 left: -6px; 161 } 162 163 .tipsy-inner { 164 background-color: ' . esc_html( $btn_hover_message_background_color ) . '; 165 color: ' . esc_html( $btn_hover_message_text_color ) . '; 166 max-width: 200px; 167 padding: 5px 8px 4px 8px; 168 text-align: center; 169 font-size: 13px; 170 } 171 .tipsy-arrow-n { 172 border-bottom-color: ' . esc_html( $btn_hover_message_background_color ) . '; 173 } 174 '; 175 wp_add_inline_style( $this->plugin_name, $llas_buttons_style ); 77 // Define all configurable styling 78 $this->define_configurable_css(); 176 79 177 80 } … … 198 101 } 199 102 103 /** 104 * Define CSS based on configured settings. 105 * 106 * @since 1.1.0 107 * @access private 108 */ 109 private function define_configurable_css() { 110 111 // Define all configurable styling here (everything else is in .css file) 112 113 $local_like_and_share_options_arr = get_option( 'local_like_and_share_settings' ); 114 115 $btn_hover_message_background_color = $local_like_and_share_options_arr['btn_hover_message_background_color']; 116 $btn_hover_message_text_color = $local_like_and_share_options_arr['btn_hover_message_text_color']; 117 118 $count_background_color = $local_like_and_share_options_arr['count_background_color']; 119 $count_outline_color = $local_like_and_share_options_arr['count_outline_color']; 120 $count_text_color = $local_like_and_share_options_arr['count_text_color']; 121 122 $like_button_color = $local_like_and_share_options_arr['like_btn_color']; 123 $like_button_hover_color = $local_like_and_share_options_arr['like_btn_hover_color']; 124 125 $share_button_color = $local_like_and_share_options_arr['share_btn_color']; 126 $share_button_hover_color = $local_like_and_share_options_arr['share_btn_hover_color']; 127 128 if ( 'left' == $local_like_and_share_options_arr['button_posn_horiz'] ) { 129 130 // Position button to left of post 131 $button_posn = 'float:left;margin:0px 10px 10px 0px'; 132 } 133 else { 134 135 // Position button to right of post 136 $button_posn = 'float:right;margin:0px 0px 10px 10px'; 137 } 138 139 $llas_buttons_style = ' 140 .llas-like-button-active { 141 ' . $button_posn . '; 142 } 143 .llas-like-button-active i { 144 cursor: pointer; 145 cursor: hand; 146 } 147 .llas-like-button-active a, 148 .llas-like-button-active a:visited, 149 .llas-like-button-active a:focus { 150 color: ' . esc_html( $like_button_color ) . '; 151 } 152 .llas-like-button-active a:hover { 153 color: ' . esc_html( $like_button_hover_color ) . '; 154 } 155 .llas-like-button-inactive { 156 ' . $button_posn . '; 157 } 158 .llas-like-button-inactive a, 159 .llas-like-button-inactive a:visited, 160 .llas-like-button-inactive a:focus, 161 .llas-like-button-inactive a:hover { 162 color: ' . esc_html( $like_button_color ) . '; 163 } 164 165 .llas-share-button-active { 166 ' . $button_posn . '; 167 } 168 .llas-share-button-active i { 169 cursor: pointer; 170 cursor: hand; 171 } 172 .llas-share-button-active a, 173 .llas-share-button-active a:visited, 174 .llas-share-button-active a:focus { 175 color: ' . esc_html( $share_button_color ) . '; 176 } 177 .llas-share-button-active a:hover { 178 color: ' . esc_html( $share_button_hover_color ) . '; 179 } 180 181 .llas-callout { 182 background-color: ' . esc_html( $count_background_color ) . '; 183 color: ' . esc_html( $count_text_color ) . '; 184 } 185 .llas-callout .llas-notch { 186 border-right: 5px solid ' . esc_html( $count_background_color ). '; 187 } 188 .llas-border-callout { 189 border: 1px solid ' . esc_html( $count_outline_color ) . '; 190 padding: 2px 9px; 191 } 192 .llas-border-callout .llas-border-notch { 193 border-right-color: ' . esc_html( $count_outline_color ) . '; 194 left: -6px; 195 } 196 197 .tipsy-inner { 198 background-color: ' . esc_html( $btn_hover_message_background_color ) . '; 199 color: ' . esc_html( $btn_hover_message_text_color ) . '; 200 max-width: 200px; 201 padding: 5px 8px 4px 8px; 202 text-align: center; 203 font-size: 13px; 204 } 205 .tipsy-arrow-n { 206 border-bottom-color: ' . esc_html( $btn_hover_message_background_color ) . '; 207 } 208 '; 209 wp_add_inline_style( $this->plugin_name, $llas_buttons_style ); 210 211 } 212 213 214 // Functions related to like and share button shortcodes 215 216 /** 217 * Register shortcodes to render Like and Share buttons directly in 218 * post/page content. 219 * 220 * @since 1.1.0 221 */ 222 public function register_shortcodes() { 223 224 add_shortcode( 'llas_like', array( $this, 'render_shortcode_button' ) ); 225 add_shortcode( 'llas_share', array( $this, 'render_shortcode_button' ) ); 226 227 } 228 229 /** 230 * Render shortcode-generated button. 231 * 232 * @since 1.1.0 233 * @param array $atts An associative array of attributes, or an empty string if no attributes are given. 234 * @param string $content The enclosed content (if the shortcode is used in its enclosing form). 235 * @param string $tag The shortcode name. 236 * @return string The HTML to render Like or Share button. 237 */ 238 public function render_shortcode_button( $atts, $content = null, $tag ) { 239 240 $type = substr( $tag, 5 ); 241 242 $clean_atts = shortcode_atts( 243 array( 244 'id' => '1' 245 ) 246 ,$atts 247 ,$tag 248 ); 249 250 $this->override_configured_css( $type, $clean_atts ); 251 252 $button_method = "add_{$type}_button_to_content"; 253 if ( method_exists( $this, $button_method ) ) { 254 255 return $this->$button_method( $clean_atts['id'] ); 256 257 } 258 259 } 260 261 /** 262 * Override configured CSS for specific shortcode-generated button, allowing 263 * for its display directly in post/page content. 264 * 265 * @since 1.1.0 266 * @access private 267 * @param string $type Type of shortcode ("like" or "share"). 268 * @param array $atts An associative array of attributes, or an empty string if no attributes are given. 269 */ 270 private function override_configured_css( $type, $atts ) { 271 272 global $post; 273 274 $post_id = get_the_ID(); 275 276 // NOTE: This is a blank stylesheet, merely used as an attachment point for wp_add_inline_style() 277 wp_enqueue_style( $this->plugin_name . '-shortcode', plugin_dir_url( __FILE__ ) . 'css/local-like-and-share-shortcode.css', array(), $this->version, 'all' ); 278 279 $llas_buttons_style = ' 280 #id_llas_spn_' . $type . '_button_' . $post_id . '_' . $atts['id'] . ' { 281 float: none; 282 } 283 '; 284 285 wp_add_inline_style( $this->plugin_name.'-shortcode', $llas_buttons_style ); 286 287 } 288 200 289 201 290 // Functions related to display of like and share buttons and (AJAX) handling of … … 212 301 213 302 global $post; 214 303 215 304 // Only show buttons on published posts 216 if ( ( 'post' != $post->post_type ) || ( 'publish' != $post->post_status ) ) {305 if ( ( 'post' != $post->post_type ) || ( 'publish' != $post->post_status ) || ( is_search() ) ) { 217 306 218 307 return $content; … … 258 347 $content = $buttons_html . '<br />' . $content; 259 348 } 260 349 261 350 return $content; 262 351 … … 306 395 * @since 1.0.0 307 396 * @access private 397 * @param string $id Shortcode ID. 308 398 * @return string The Like button HTML. 309 399 */ 310 private function add_like_button_to_content( ) {400 private function add_like_button_to_content( $id = 'classic' ) { 311 401 312 402 global $post; 313 403 global $wpdb; 314 404 405 $post_id = get_the_ID(); 406 315 407 $local_like_and_share_options_arr = get_option( 'local_like_and_share_settings' ); 316 408 317 409 // Get like total for specific post from post meta data 318 $like_total = get_post_meta( get_the_ID(), 'local_like_and_share_like_total', true );410 $like_total = get_post_meta( $post_id, 'local_like_and_share_like_total', true ); 319 411 if ( empty( $like_total ) ) { 320 412 $like_total = 0; … … 324 416 325 417 $like_count_span = 326 '<span id="id_ spnLikeCount" class="llas-callout llas-border-callout">'418 '<span id="id_llas_spn_like_count_' . $post_id . '_' . $id . '" class="llas-callout llas-border-callout">' 327 419 . Local_Like_And_Share_Misc::format_count_display( $like_total ) 328 420 . '<b class="llas-border-notch llas-notch"></b>' … … 331 423 ; 332 424 333 $user_already_liked = $this->current_user_already_liked_post( $this->get_current_user_identifier(), get_the_ID());425 $user_already_liked = $this->current_user_already_liked_post( $this->get_current_user_identifier(), $post_id ); 334 426 if ( $user_already_liked ) { 335 427 … … 337 429 $button_link = '<a id="id_dummy" rel="tipsy" title="' . esc_attr( $local_like_and_share_options_arr['like_btn_hover_info_message_already_liked'] ) . '">'; 338 430 339 $like_button = '< div class="llas-like-button-inactive">'431 $like_button = '<span class="llas-like-button-inactive" id="id_llas_spn_like_button_' . $post_id . '_' . $id . '">' 340 432 . $button_link 341 433 . $button_icon 342 434 . '</a>' 343 435 . $like_count_span 344 . '</ div>'436 . '</span>' 345 437 ; 346 438 … … 349 441 350 442 // Current user/visitor has NOT yet liked this post 351 $button_link = '<a class="like_button" id="id_l nkLikeButton_' . get_the_ID() . '" data-post-id="' . get_the_ID(). '" rel="tipsy" title="' . esc_attr( $local_like_and_share_options_arr['like_btn_hover_call_to_action'] ) . '">';352 353 $like_button = '< div class="llas-like-button-active" id="id_divLikeButton_' . get_the_ID(). '">'443 $button_link = '<a class="like_button" id="id_llas_lnk_like_button_' . $post_id . '_' . $id . '" data-post-id="' . $post_id . '" rel="tipsy" title="' . esc_attr( $local_like_and_share_options_arr['like_btn_hover_call_to_action'] ) . '">'; 444 445 $like_button = '<span class="llas-like-button-active" id="id_llas_spn_like_button_' . $post_id . '_' . $id . '">' 354 446 . $button_link 355 447 . $button_icon 356 448 . '</a>' 357 449 . $like_count_span 358 . '</ div>'450 . '</span>' 359 451 ; 360 452 … … 432 524 * @since 1.0.0 433 525 * @access private 526 * @param string $id Shortcode ID. 434 527 * @return string The Share button HTML. 435 528 */ 436 private function add_share_button_to_content( ) {529 private function add_share_button_to_content( $id = 'classic' ) { 437 530 438 531 global $post; 439 532 global $wpdb; 440 533 534 $post_id = get_the_ID(); 535 441 536 $local_like_and_share_options_arr = get_option( 'local_like_and_share_settings' ); 442 537 443 538 // Get share total for specific post from post meta data 444 $share_total = get_post_meta( get_the_ID(), 'local_like_and_share_share_total', true );539 $share_total = get_post_meta( $post_id, 'local_like_and_share_share_total', true ); 445 540 if ( empty( $share_total ) ) { 446 541 $share_total = 0; … … 450 545 451 546 $share_count_span = 452 '<span id="id_ spnShareCount" class="llas-callout llas-border-callout">'547 '<span id="id_llas_spn_share_count" class="llas-callout llas-border-callout">' 453 548 . Local_Like_And_Share_Misc::format_count_display( $share_total ) 454 549 . '<b class="llas-border-notch llas-notch"></b>' … … 462 557 // Replace variables in both the share post email subject and body 463 558 464 $post_attribs = get_post( get_the_ID());559 $post_attribs = get_post( $post_id ); 465 560 $post_title = $post_attribs->post_title; 466 $post_permalink = get_permalink( get_the_ID());561 $post_permalink = get_permalink( $post_id ); 467 562 468 563 $share_email_subject = $local_like_and_share_options_arr['share_eml_subj']; … … 482 577 . '&body=' . esc_attr( $share_email_body ) 483 578 . '" ' 484 . 'id="id_l nkShareButton_' . get_the_ID() . '" data-post-id="' . get_the_ID(). '" rel="tipsy" title="' . esc_attr( $local_like_and_share_options_arr['share_btn_hover_call_to_action'] ) . '">';485 486 $share_button = '< div class="llas-share-button-active" id="id_divShareButton_' . get_the_ID(). '">'579 . 'id="id_llas_lnk_share_button_' . $post_id . '_' . $id . '" data-post-id="' . $post_id . '" rel="tipsy" title="' . esc_attr( $local_like_and_share_options_arr['share_btn_hover_call_to_action'] ) . '">'; 580 581 $share_button = '<span class="llas-share-button-active" id="id_llas_spn_share_button_' . $post_id . '_' . $id . '">' 487 582 . $button_link 488 583 . $button_icon 489 584 . '</a>' 490 585 . $share_count_span 491 . '</ div>'586 . '</span>' 492 587 ; 493 588 … … 495 590 496 591 } 497 498 /** 499 * Enqueue AJAX script that fires when "Like" button (on post) is pressed.500 * 501 * @since 1. 0.0592 593 /** 594 * Localize AJAX script that fires when "Like" button (on post/page) is pressed. 595 * 596 * @since 1.1.0 502 597 * @param string $hook The current page name. 503 598 */ 504 public function l ike_button_clicked_enqueue( $hook ) {599 public function localize_like_button_handler_script( $hook ) { 505 600 506 601 $like_button_clicked_nonce = wp_create_nonce( 'like_button_clicked' ); … … 533 628 $button_id = $_POST['btn_id']; 534 629 535 // Button number starts at position 17 in $button_id (due to prefix of 'id_lnkLikeButton_')536 $button_num = substr( $button_id, 17);537 538 630 // Get like total for specific post from post meta data 539 631 $like_total = get_post_meta( $post_id, 'local_like_and_share_like_total', true ); … … 555 647 $like_total += 1; 556 648 $like_count_span = 557 '<span id="id_ spnLikeCount" class="llas-callout llas-border-callout">'649 '<span id="id_llas_spn_like_count" class="llas-callout llas-border-callout">' 558 650 . Local_Like_And_Share_Misc::format_count_display( $like_total ) 559 651 . '<b class="llas-border-notch llas-notch"></b>' … … 598 690 // Manually kill AJAX handler 599 691 wp_die(); 692 600 693 } 601 694 } … … 604 697 // User ALREADY liked this! 605 698 $like_count_span = 606 '<span id="id_ spnLikeCount" class="llas-callout llas-border-callout">'699 '<span id="id_llas_spn_like_count" class="llas-callout llas-border-callout">' 607 700 . Local_Like_And_Share_Misc::format_count_display( $like_total ) 608 701 . '<b class="llas-border-notch llas-notch"></b>' … … 623 716 } 624 717 625 wp_send_json( array( ' button_num' => $button_num, 'message' => $like_button_clicked_msg ) );718 wp_send_json( array( 'post_id' => $post_id, 'message' => $like_button_clicked_msg ) ); 626 719 627 720 } 628 721 629 722 /** 630 * Enqueue AJAX script that fires when "Share" button (on post) is pressed.631 * 632 * @since 1. 0.0723 * Localize AJAX script that fires when "Share" button (on post/page) is pressed. 724 * 725 * @since 1.1.0 633 726 * @param string $hook The current page name. 634 727 */ 635 public function share_button_clicked_enqueue( $hook ) {728 public function localize_share_button_handler_script( $hook ) { 636 729 637 730 $share_button_clicked_nonce = wp_create_nonce( 'share_button_clicked' ); … … 694 787 wp_die(); 695 788 696 } 697 789 } 790 698 791 } -
local-like-and-share/trunk/public/js/local-like-and-share-public.js
r1309636 r1809716 16 16 // Hide old Tipsy tooltip 17 17 $('.tipsy:last').remove(); 18 19 // Deactivate button 20 jQuery("#id_divLikeButton_" + data.button_num).removeClass("llas-like-button-active").addClass("llas-like-button-inactive"); 21 22 // Render deactivated button, new tooltip message, and updated like count 23 jQuery("#id_divLikeButton_" + data.button_num).html(data.message); 18 19 // Handle (potentially) multiple like buttons, per post/page 20 $("[id^=id_llas_spn_like_button_"+data.post_id+"]").each(function(index) { 21 22 // Deactivate button 23 $(this).removeClass("llas-like-button-active").addClass("llas-like-button-inactive"); 24 25 // Render deactivated button, new tooltip message, and updated like count, for each button 26 $(this).html(data.message); 27 }); 28 24 29 $('a[rel="tipsy"]').tipsy({fade: true, opacity: 1}); 25 30 }); -
local-like-and-share/trunk/public/js/local-like-and-share-public.min.js
r1379566 r1809716 1 !function(t){"use strict";function i(t,i){return"function"==typeof t?t.call(i):t}function e(t){for(;t=t.parentNode;)if(t==document)return!0;return!1}function n(i,e){this.$element=t(i),this.options=e,this.enabled=!0,this.fixTitle()}t(function(){t(".like_button").click(function(i){var e=t(this),n=e.data("post-id"),s=e.attr("id");t.post(like_button_clicked_ajax_obj.ajax_url,{_ajax_nonce:like_button_clicked_ajax_obj.nonce,action:"like_button_clicked",post_id:n,btn_id:s},function(i){t(".tipsy:last").remove(),jQuery("#id_divLikeButton_"+i.button_num).removeClass("llas-like-button-active").addClass("llas-like-button-inactive"),jQuery("#id_divLikeButton_"+i.button_num).html(i.message),t('a[rel="tipsy"]').tipsy({fade:!0,opacity:1})})})}),t(function(){t(".share_button").click(function(i){var e=t(this),n=e.data("post-id");t.post(share_button_clicked_ajax_obj.ajax_url,{_ajax_nonce:share_button_clicked_ajax_obj.nonce,action:"share_button_clicked",post_id:n},function(t){location.reload()})})}),t(function(){t('a[rel="tipsy"]').tipsy({fade:!0,opacity:1})}),n.prototype={show:function(){var e=this.getTitle();if(e&&this.enabled){var n=this.tip();n.find(".tipsy-inner")[this.options.html?"html":"text"](e),n[0].className="tipsy",n.remove().css({top:0,left:0,visibility:"hidden",display:"block"}).prependTo(document.body);var s,o=t.extend({},this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight}),a=n[0].offsetWidth,l=n[0].offsetHeight,f=i(this.options.gravity,this.$element[0]);switch(f.charAt(0)){case"n":s={top:o.top+o.height+this.options.offset,left:o.left+o.width/2-a/2};break;case"s":s={top:o.top-l-this.options.offset,left:o.left+o.width/2-a/2};break;case"e":s={top:o.top+o.height/2-l/2,left:o.left-a-this.options.offset};break;case"w":s={top:o.top+o.height/2-l/2,left:o.left+o.width+this.options.offset}}2==f.length&&("w"==f.charAt(1)?s.left=o.left+o.width/2-15:s.left=o.left+o.width/2-a+15),n.css(s).addClass("tipsy-"+f),n.find(".tipsy-arrow")[0].className="tipsy-arrow tipsy-arrow-"+f.charAt(0),this.options.className&&n.addClass(i(this.options.className,this.$element[0])),this.options.fade?n.stop().css({opacity:0,display:"block",visibility:"visible"}).animate({opacity:this.options.opacity}):n.css({visibility:"visible",opacity:this.options.opacity})}},hide:function(){this.options.fade?this.tip().stop().fadeOut(function(){t(this).remove()}):this.tip().remove()},fixTitle:function(){var t=this.$element;(t.attr("title")||"string"!=typeof t.attr("original-title"))&&t.attr("original-title",t.attr("title")||"").removeAttr("title")},getTitle:function(){var t,i=this.$element,e=this.options;this.fixTitle();var t,e=this.options;return"string"==typeof e.title?t=i.attr("title"==e.title?"original-title":e.title):"function"==typeof e.title&&(t=e.title.call(i[0])),t=(""+t).replace(/(^\s*|\s*$)/,""),t||e.fallback},tip:function(){return this.$tip||(this.$tip=t('<div class="tipsy"></div>').html('<div class="tipsy-arrow"></div><div class="tipsy-inner"></div>'),this.$tip.data("tipsy-pointee",this.$element[0])),this.$tip},validate:function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},toggleEnabled:function(){this.enabled=!this.enabled}},t.fn.tipsy=function(i){function e(e){var s=t.data(e,"tipsy");return s||(s=new n(e,t.fn.tipsy.elementOptions(e,i)),t.data(e,"tipsy",s)),s}function s(){var t=e(this);t.hoverState="in",0==i.delayIn?t.show():(t.fixTitle(),setTimeout(function(){"in"==t.hoverState&&t.show()},i.delayIn))}function o(){var t=e(this);t.hoverState="out",0==i.delayOut?t.hide():setTimeout(function(){"out"==t.hoverState&&t.hide()},i.delayOut)}if(i===!0)return this.data("tipsy");if("string"==typeof i){var a=this.data("tipsy");return a&&a[i](),this}if(i=t.extend({},t.fn.tipsy.defaults,i),i.live||this.each(function(){e(this)}),"manual"!=i.trigger){var l=i.live?"live":"bind",f="hover"==i.trigger?"mouseenter":"focus",r="hover"==i.trigger?"mouseleave":"blur";this[l](f,s)[l](r,o)}return this},t.fn.tipsy.defaults={className:null,delayIn:0,delayOut:0,fade:!1,fallback:"",gravity:"n",html:!1,live:!1,offset:0,opacity:.8,title:"title",trigger:"hover"},t.fn.tipsy.revalidate=function(){t(".tipsy").each(function(){var i=t.data(this,"tipsy-pointee");i&&e(i)||t(this).remove()})},t.fn.tipsy.elementOptions=function(i,e){return t.metadata?t.extend({},e,t(i).metadata()):e},t.fn.tipsy.autoNS=function(){return t(this).offset().top>t(document).scrollTop()+t(window).height()/2?"s":"n"},t.fn.tipsy.autoWE=function(){return t(this).offset().left>t(document).scrollLeft()+t(window).width()/2?"e":"w"},t.fn.tipsy.autoBounds=function(i,e){return function(){var n={ns:e[0],ew:e.length>1?e[1]:!1},s=t(document).scrollTop()+i,o=t(document).scrollLeft()+i,a=t(this);return a.offset().top<s&&(n.ns="n"),a.offset().left<o&&(n.ew="w"),t(window).width()+t(document).scrollLeft()-a.offset().left<i&&(n.ew="e"),t(window).height()+t(document).scrollTop()-a.offset().top<i&&(n.ns="s"),n.ns+(n.ew?n.ew:"")}}}(jQuery);1 !function(t){"use strict";function i(t,i){return"function"==typeof t?t.call(i):t}function e(t){for(;t=t.parentNode;)if(t==document)return!0;return!1}function s(i,e){this.$element=t(i),this.options=e,this.enabled=!0,this.fixTitle()}t(function(){t(".like_button").click(function(i){var e=t(this),s=e.data("post-id"),n=e.attr("id");t.post(like_button_clicked_ajax_obj.ajax_url,{_ajax_nonce:like_button_clicked_ajax_obj.nonce,action:"like_button_clicked",post_id:s,btn_id:n},function(i){t(".tipsy:last").remove(),t("[id^=id_llas_spn_like_button_"+i.post_id+"]").each(function(e){t(this).removeClass("llas-like-button-active").addClass("llas-like-button-inactive"),t(this).html(i.message)}),t('a[rel="tipsy"]').tipsy({fade:!0,opacity:1})})})}),t(function(){t(".share_button").click(function(i){var e=t(this).data("post-id");t.post(share_button_clicked_ajax_obj.ajax_url,{_ajax_nonce:share_button_clicked_ajax_obj.nonce,action:"share_button_clicked",post_id:e},function(t){location.reload()})})}),t(function(){t('a[rel="tipsy"]').tipsy({fade:!0,opacity:1})}),s.prototype={show:function(){var e=this.getTitle();if(e&&this.enabled){var s=this.tip();s.find(".tipsy-inner")[this.options.html?"html":"text"](e),s[0].className="tipsy",s.remove().css({top:0,left:0,visibility:"hidden",display:"block"}).prependTo(document.body);var n,o=t.extend({},this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight}),a=s[0].offsetWidth,l=s[0].offsetHeight,f=i(this.options.gravity,this.$element[0]);switch(f.charAt(0)){case"n":n={top:o.top+o.height+this.options.offset,left:o.left+o.width/2-a/2};break;case"s":n={top:o.top-l-this.options.offset,left:o.left+o.width/2-a/2};break;case"e":n={top:o.top+o.height/2-l/2,left:o.left-a-this.options.offset};break;case"w":n={top:o.top+o.height/2-l/2,left:o.left+o.width+this.options.offset}}2==f.length&&("w"==f.charAt(1)?n.left=o.left+o.width/2-15:n.left=o.left+o.width/2-a+15),s.css(n).addClass("tipsy-"+f),s.find(".tipsy-arrow")[0].className="tipsy-arrow tipsy-arrow-"+f.charAt(0),this.options.className&&s.addClass(i(this.options.className,this.$element[0])),this.options.fade?s.stop().css({opacity:0,display:"block",visibility:"visible"}).animate({opacity:this.options.opacity}):s.css({visibility:"visible",opacity:this.options.opacity})}},hide:function(){this.options.fade?this.tip().stop().fadeOut(function(){t(this).remove()}):this.tip().remove()},fixTitle:function(){var t=this.$element;(t.attr("title")||"string"!=typeof t.attr("original-title"))&&t.attr("original-title",t.attr("title")||"").removeAttr("title")},getTitle:function(){var t=this.$element,i=this.options;this.fixTitle();var e;return"string"==typeof(i=this.options).title?e=t.attr("title"==i.title?"original-title":i.title):"function"==typeof i.title&&(e=i.title.call(t[0])),(e=(""+e).replace(/(^\s*|\s*$)/,""))||i.fallback},tip:function(){return this.$tip||(this.$tip=t('<div class="tipsy"></div>').html('<div class="tipsy-arrow"></div><div class="tipsy-inner"></div>'),this.$tip.data("tipsy-pointee",this.$element[0])),this.$tip},validate:function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},toggleEnabled:function(){this.enabled=!this.enabled}},t.fn.tipsy=function(i){function e(e){var n=t.data(e,"tipsy");return n||(n=new s(e,t.fn.tipsy.elementOptions(e,i)),t.data(e,"tipsy",n)),n}if(!0===i)return this.data("tipsy");if("string"==typeof i){var n=this.data("tipsy");return n&&n[i](),this}if((i=t.extend({},t.fn.tipsy.defaults,i)).live||this.each(function(){e(this)}),"manual"!=i.trigger){var o=i.live?"live":"bind",a="hover"==i.trigger?"mouseenter":"focus",l="hover"==i.trigger?"mouseleave":"blur";this[o](a,function(){var t=e(this);t.hoverState="in",0==i.delayIn?t.show():(t.fixTitle(),setTimeout(function(){"in"==t.hoverState&&t.show()},i.delayIn))})[o](l,function(){var t=e(this);t.hoverState="out",0==i.delayOut?t.hide():setTimeout(function(){"out"==t.hoverState&&t.hide()},i.delayOut)})}return this},t.fn.tipsy.defaults={className:null,delayIn:0,delayOut:0,fade:!1,fallback:"",gravity:"n",html:!1,live:!1,offset:0,opacity:.8,title:"title",trigger:"hover"},t.fn.tipsy.revalidate=function(){t(".tipsy").each(function(){var i=t.data(this,"tipsy-pointee");i&&e(i)||t(this).remove()})},t.fn.tipsy.elementOptions=function(i,e){return t.metadata?t.extend({},e,t(i).metadata()):e},t.fn.tipsy.autoNS=function(){return t(this).offset().top>t(document).scrollTop()+t(window).height()/2?"s":"n"},t.fn.tipsy.autoWE=function(){return t(this).offset().left>t(document).scrollLeft()+t(window).width()/2?"e":"w"},t.fn.tipsy.autoBounds=function(i,e){return function(){var s={ns:e[0],ew:e.length>1&&e[1]},n=t(document).scrollTop()+i,o=t(document).scrollLeft()+i,a=t(this);return a.offset().top<n&&(s.ns="n"),a.offset().left<o&&(s.ew="w"),t(window).width()+t(document).scrollLeft()-a.offset().left<i&&(s.ew="e"),t(window).height()+t(document).scrollTop()-a.offset().top<i&&(s.ns="s"),s.ns+(s.ew?s.ew:"")}}}(jQuery);
Note: See TracChangeset
for help on using the changeset viewer.