Plugin Directory

Changeset 1680735


Ignore:
Timestamp:
06/18/2017 07:11:27 PM (9 years ago)
Author:
theode
Message:

Update to count only once

Location:
emojized
Files:
11 added
4 edited

Legend:

Unmodified
Added
Removed
  • emojized/trunk/emojized-endpoints.php

    r1432680 r1680735  
    2323
    2424    $count = get_post_meta($id, 'count', true);
    25     $count++;
     25    $counted_once = get_post_meta($id, 'counted_once', true);
     26
     27    if
     28    ($counted_once == 'on')
     29    {
     30        $voters = get_post_meta($id, 'voters', true);
     31        $ip = $_SERVER['REMOTE_ADDR'];
     32        $ip_hashed = substr(base_convert(md5($ip), 16, 32), 0, 12);
     33        $voters_array = explode(';', $voters);
     34        if
     35        (!in_array( $ip_hashed, $voters_array))
     36        {
     37            $count++;
     38            $voters_and_new_vote = array_merge($voters, array($ip_hashed));
     39            update_post_meta($id, 'voters', $voters.$ip_hashed.';');
     40        }
     41    }
     42    else
     43    {
     44        $count++;
     45    }
    2646    update_post_meta($id, 'count', $count);
    2747
    2848    return $count;
    2949}
     50
    3051?>
  • emojized/trunk/emojized-metabox.php

    r1432680 r1680735  
    11<?php
     2
     3function emojized_wp_admin_style()
     4{
     5    wp_enqueue_style( 'emojized-backend' , plugin_dir_url( __FILE__ ) . 'css/emojized.css');
     6}
     7
     8add_action( 'admin_enqueue_scripts', 'emojized_wp_admin_style' );
    29function emojized_meta_boxes( $post )
    310{
     
    1825    global $post;
    1926    wp_nonce_field( plugin_basename( __FILE__ ), 'emojized_nonce' );
    20     echo '<table>';
    21     echo '<tr><th>ID</th><th>Emoji</th><th>Count</th><th>Initial Count</th><th>Shortcode</th></tr>';
    22     echo '<tr><td><h1>ID : '.$post->ID.'</h1></td>';
    23     echo '<td>';
     27    echo '<div class="emojized-table">';
     28
     29    echo '<div class="row">';
     30    // row start
     31    echo '<div class="column head">ID</div>';
     32    echo '<div class="column head">Emoji</div>';
     33    echo '<div class="column head">Count</div>';
     34    echo '<div class="column head">Initial Count</div>';
     35    echo '<div class="column head">Shortcode</div>';
     36    echo '</div>';
     37    // row end
     38    echo '<div class="row">';
     39    // row start
     40    echo '<div class="column"><h1>ID : '.$post->ID.'</h1></div>';
     41
     42    echo '<div class="column">';
    2443    $emoji = get_post_meta($post->ID, 'emoji', true);
    25     echo '<input name="emoji" type="text" style="font-size:64px;height:75px;width:75px;" value="' .esc_attr($emoji). '" /></td>';
     44    echo '<input name="emoji" type="text" class="emoji" value="' .esc_attr($emoji). '" /></div>';
     45
    2646    $count = get_post_meta($post->ID, 'count', true);
    27     echo '<td><input name="count" type="number" style="font-size:64px;height:75px;width:300px;" value="' .esc_attr($count). '" /></td>';
     47    echo '<div class="column"><input name="count" type="number" class="count" value="' .esc_attr($count). '" /></div>';
     48
    2849    $initial_count = get_post_meta($post->ID, 'initial_count', true);
    29     echo '<td><input name="initial_count" type="number" style="font-size:64px;height:75px;width:300px;" value="' .esc_attr($initial_count). '" /></td>';
    30     echo '<td><h2>[emojized id="' .$post->ID . '" count="true"]</h3></td>';
    31     echo '</tr></table>';
     50    echo '<div class="column"><input name="initial_count" type="number"class="count" value="' .esc_attr($initial_count). '" /></div>';
    3251
     52    echo '<div class="column"><h2>[emojized id="' .$post->ID . '" count="true"]</h3></div>';
     53    echo '</div>';
     54    // row end
     55    echo '<div class="row">';
     56    echo '<div class="column head">Settings</div>';
     57    echo '</div>';
     58
     59    echo '<div class="row">';
     60    echo '<div class="column">one vote per user</div>';
     61    $counted_once = get_post_meta($post->ID, 'counted_once', true);
     62    echo '<div class="column"><input type="checkbox" name="counted_once" ';
     63    if
     64    ($counted_once) echo 'checked=checked ';
     65    echo '/>';
     66    echo '</div>';
     67    echo '</div>';
     68
     69    echo '</div>';
     70    // table end
    3371}
    3472
     
    4482    $count = sanitize_text_field( $_POST['count'] );
    4583    $initial_count = sanitize_text_field( $_POST['initial_count'] );
     84    $counted_once = $_POST['counted_once'];
    4685
    4786    update_post_meta($post->ID, 'emoji', $emoji);
    4887    update_post_meta($post->ID, 'count', $count);
    4988    update_post_meta($post->ID, 'initial_count', $initial_count);
     89    update_post_meta($post->ID, 'counted_once', $counted_once);
    5090}
    5191
  • emojized/trunk/emojized.php

    r1432680 r1680735  
    55Description: This is a plugin which is making emojis automatically
    66Author: Emojized
    7 Version: 0.1
     7Version: 0.2
    88Author URI: http://emojized.com
    99Licence: GPL2
    1010*/
    11 
    1211
    1312include 'emojized-metabox.php';
     
    1514include 'emojized-endpoints.php';
    1615
    17 
    18 
    1916?>
  • emojized/trunk/readme.txt

    r1432680 r1680735  
    33Tags: reactions, emoji, voting, poll 
    44Requires at least: 4.5
    5 Tested up to: 4.5.2
     5Tested up to: 4.9
    66Stable tag: 0.1
    77License: GPLv2   
     
    1515So you install the plugin and create new emoji with a title an emoji itself, a count field and an initial count, to fake the initial value of the clicked emoji.
    1616The shortcake is [emojized id=“8” count=“true”]  (or false or empty)
     17
     18In the new version you can limit votes to one per user.
     19
     20This plugin demands WP REST API plugin.
    1721
    1822It has the same approach as the plugin “Emoji Reactions”
     
    4751= 0.1 =
    4852* initial release
     53
     54= 0.2 =
     55* Vote once update
Note: See TracChangeset for help on using the changeset viewer.