Changeset 2956410
- Timestamp:
- 08/21/2023 08:15:56 PM (3 years ago)
- Location:
- mi13-like/trunk
- Files:
-
- 2 edited
-
mi13-like.php (modified) (10 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mi13-like/trunk/mi13-like.php
r2952353 r2956410 3 3 Plugin Name: mi13-like 4 4 Plugin URI: https://wordpress.org/plugins/mi13-like/ 5 Description: The plugin likes for your posts.6 Version: 0.1505 Description: The plugin likes for your posts. 6 Version: 0.151 7 7 Author: mi13 8 8 … … 55 55 56 56 function mi13_like_scripts() { 57 if (is_sing le()) {57 if (is_singular()) { 58 58 wp_enqueue_style('mi13-like', plugins_url('/css/mi13_like.css',__FILE__), false,'0.1','all'); 59 59 wp_enqueue_style('mi13-like-icomoon', plugins_url('/css/icomoon/style.css',__FILE__), false,'0.1','all'); 60 60 wp_enqueue_script('mi13_like', plugins_url('/js/mi13_like.js',__FILE__), array(),'0.3',true); 61 61 wp_localize_script('mi13_like', 'mi13_like_ajax', 62 array(63 'url' => admin_url('admin-ajax.php'),64 'nonce' => wp_create_nonce('mi13_like'),65 'message' => __('error: Cookies are blocked or not supported by your browser.','mi13-like')62 array( 63 'url' => admin_url('admin-ajax.php'), 64 'nonce' => wp_create_nonce('mi13_like'), 65 'message' => __('error: Cookies are blocked or not supported by your browser.','mi13-like') 66 66 ) 67 ); 67 ); 68 68 } 69 69 } … … 130 130 else $paged = (isset($_GET['like_page']) && intval($_GET['like_page'])>1) ? intval($_GET['like_page']) : 1; 131 131 $args = array( 132 'post_type' => 'post',132 'post_type' => ['post','page'], 133 133 'posts_per_page' => 10, 134 134 'paged' => $paged, … … 162 162 while( $like_posts->have_posts() ){ 163 163 $like_posts->the_post(); 164 $dislike = intval(get_post_meta (get_the_ID(),'mi13_like_down',true)); 164 $type = get_post_type() == 'page' ? '*' : ''; 165 $dislike = intval(get_post_meta(get_the_ID(),'mi13_like_down',true)); 165 166 $like = intval(get_post_meta (get_the_ID(),'mi13_like_up',true)); 166 167 if (($like>10) || ($dislike>10)) $rating = round($like / (($like + $dislike) / 100)) . '%'; … … 169 170 '<tr '.$alternate.'> 170 171 <td class="column-name">'.get_the_ID().'</td> 171 <td class="column-name">'.get_the_title(). '</td>172 <td class="column-name">'.get_the_title().$type.'</td> 172 173 <td class="column-name">'.$like.'</td> 173 174 <td class="column-name">'.$dislike.'</td> … … 234 235 </tr> 235 236 <tr> 236 <th scope="row"><?php _e('Block likes placed at the end of the post automatically:','mi13-like'); ?> </th>237 <th scope="row"><?php _e('Block likes placed at the end of the post automatically:','mi13-like'); ?> (only for posts)</th> 237 238 <td><input type="checkbox" name="mi13_like[add_to_content]" value="1" <?php checked(1,get_option('mi13_like')['add_to_content']); ?> ></td> 238 239 </tr> … … 265 266 </form> 266 267 <p><?php _e('All available styles for <strong>like class and dislike class</strong> you can see in <strong>IcoMoon demo</strong>','mi13-like'); ?></p> 267 <p>Code Snippet: <?php if (function_exists('mi13_like')) echo mi13_like( ); ?></p>268 <p>Code Snippet: <?php if (function_exists('mi13_like')) echo mi13_like($id=0, $div='div'); ?></p> 268 269 </div> 269 270 <?php … … 271 272 272 273 function mi13_like( $id=0, $div='div') { 273 if (is_single()) {274 if( is_singular() ) { 274 275 if ($id == 0) { 275 276 global $post; … … 318 319 $button_like = '<i id="mi13_like_up" onclick="mi13_like(' . $id . ',\'' . $flag . '\')" class="'.$like_class.'" role="button" title="'.$title_like.'" style="'.$style.$style_like.'" aria-label="like"></i>'; 319 320 $button_dislike = '<i id="mi13_like_down" onclick="mi13_like(' . $id . ',\'' . $flag . '\')" class="'.$dislike_class.'" role="button" title="'.$title_dislike.'" style="'.$style.$style_dislike.'" aria-label="dislike"></i>'; 320 return '<'.$div_open.' class="mi13_like" aria-hidden="true">'.$button_like.'<span class="mi13_like_like">'.$like.'</span>'.$button_dislike.'<span class="mi13_like_dislike">'.$dislike.'</span><span class="mi13_like_note">'.$note.'</span></'.$div.'>'; 321 } 322 } else return false;321 return '<'.$div_open.' class="mi13_like" aria-hidden="true">'.$button_like.'<span class="mi13_like_like">'.$like.'</span>'.$button_dislike.'<span class="mi13_like_dislike">'.$dislike.'</span><span class="mi13_like_note">'.$note.'</span></'.$div.'>'; 322 } else return false; 323 } 323 324 } 324 325 325 326 function mi13_like_content($content) { 326 if (get_option('mi13_like')['add_to_content']=='1') return $content . mi13_like(); 327 else return $content; 327 if( is_single() ) { //only posts 328 if (get_option('mi13_like')['add_to_content']=='1') $content .= mi13_like(); 329 } 330 return $content; 328 331 } 329 332 add_filter( 'the_content', 'mi13_like_content', isset(get_option('mi13_like')['priority']) ? get_option('mi13_like')['priority'] : 11 ); … … 415 418 if ($str === false) { 416 419 $ar_s = array( 417 'post_type' => 'post',420 'post_type' => ['post','page'], 418 421 'post_status' => 'publish', 419 422 'posts_per_page' => $top_posts_count, -
mi13-like/trunk/readme.txt
r2952353 r2956410 4 4 Requires at least: 4.7 5 5 Tested up to: 6.3 6 Stable tag: 0.15 06 Stable tag: 0.151 7 7 8 8 Плагин лайков для ваших постов. … … 59 59 = 0.150 = 60 60 * Теперь не требуется jquery во фронтенде. 61 = 0.151 = 62 * Теперь страницы доступны для лайков.
Note: See TracChangeset
for help on using the changeset viewer.