Plugin Directory

Changeset 2956410


Ignore:
Timestamp:
08/21/2023 08:15:56 PM (3 years ago)
Author:
mi13
Message:

Update plugin

Location:
mi13-like/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • mi13-like/trunk/mi13-like.php

    r2952353 r2956410  
    33Plugin Name:    mi13-like
    44Plugin URI:     https://wordpress.org/plugins/mi13-like/
    5 Description:        The plugin likes for your posts.
    6 Version:            0.150
     5Description:    The plugin likes for your posts.
     6Version:        0.151
    77Author:         mi13
    88 
     
    5555   
    5656function mi13_like_scripts() {
    57     if (is_single()) {
     57    if (is_singular()) {
    5858        wp_enqueue_style('mi13-like', plugins_url('/css/mi13_like.css',__FILE__), false,'0.1','all');
    5959        wp_enqueue_style('mi13-like-icomoon', plugins_url('/css/icomoon/style.css',__FILE__), false,'0.1','all');
    6060        wp_enqueue_script('mi13_like', plugins_url('/js/mi13_like.js',__FILE__), array(),'0.3',true);
    6161        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')
    6666            )
    67         );     
     67        );
    6868    }
    6969}
     
    130130    else $paged = (isset($_GET['like_page']) && intval($_GET['like_page'])>1) ? intval($_GET['like_page']) : 1;
    131131    $args = array(
    132         'post_type' => 'post',
     132        'post_type' => ['post','page'],
    133133        'posts_per_page' => 10,
    134134        'paged' => $paged,
     
    162162    while( $like_posts->have_posts() ){
    163163        $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));
    165166        $like = intval(get_post_meta (get_the_ID(),'mi13_like_up',true));
    166167        if (($like>10) || ($dislike>10)) $rating = round($like / (($like + $dislike) / 100)) . '%';
     
    169170        '<tr '.$alternate.'>
    170171            <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>
    172173            <td class="column-name">'.$like.'</td>
    173174            <td class="column-name">'.$dislike.'</td>
     
    234235                  </tr>
    235236                  <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>
    237238                   <td><input type="checkbox" name="mi13_like[add_to_content]" value="1" <?php checked(1,get_option('mi13_like')['add_to_content']); ?> ></td>
    238239                  </tr>
     
    265266        </form>
    266267        <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: &lt;?php if (function_exists('mi13_like')) echo mi13_like(); ?&gt;</p>
     268        <p>Code Snippet: &lt;?php if (function_exists('mi13_like')) echo mi13_like($id=0, $div='div'); ?&gt;</p>
    268269    </div>
    269270    <?php
     
    271272
    272273function mi13_like( $id=0, $div='div') {
    273     if (is_single()) {
     274    if( is_singular() ) {
    274275        if ($id == 0) {
    275276            global $post;
     
    318319            $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>';
    319320            $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    }
    323324}
    324325
    325326function 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;
    328331}
    329332add_filter( 'the_content', 'mi13_like_content', isset(get_option('mi13_like')['priority']) ? get_option('mi13_like')['priority'] : 11 );
     
    415418    if ($str === false) {
    416419        $ar_s = array(
    417             'post_type' => 'post',
     420            'post_type' => ['post','page'],
    418421            'post_status' => 'publish',
    419422            'posts_per_page' => $top_posts_count,
  • mi13-like/trunk/readme.txt

    r2952353 r2956410  
    44Requires at least: 4.7
    55Tested up to: 6.3
    6 Stable tag: 0.150
     6Stable tag: 0.151
    77
    88Плагин лайков для ваших постов.
     
    5959= 0.150 =
    6060* Теперь не требуется jquery во фронтенде.
     61= 0.151 =
     62* Теперь страницы доступны для лайков.
Note: See TracChangeset for help on using the changeset viewer.