Exemplo n.º 1
0
function likebtn_review_notice()
{
    global $wpdb;
    $votes_level = 10;
    $likebtn_review = (int) get_option('likebtn_review');
    // Check
    if (_likebtn_is_stat_enabled() && !$likebtn_review) {
        $query_prepared = "\n            SELECT count(ID) \n            FROM " . $wpdb->prefix . LIKEBTN_TABLE_VOTE . " \n        ";
        $votes_count = $wpdb->get_var($query_prepared);
        if ((int) $votes_count > $votes_level) {
            $likebtn_review = 1;
            update_option('likebtn_review', $likebtn_review);
            $votes = floor($votes_count / 10) * 10;
        }
    }
    if ($likebtn_review > 0) {
        $msg = strtr('<strong>' . __(LIKEBTN_PLUGIN_TITLE, LIKEBTN_I18N_DOMAIN) . '</strong>: ' . __('Congrats!</strong> Your website crossed the <strong>%votes% votes</strong> – that’s awesome! If you like the plugin you can submit a review <a href="%url_review%" target="_blank">here</a>.', LIKEBTN_I18N_DOMAIN), array('%url_review%' => 'https://wordpress.org/support/view/plugin-reviews/likebtn-like-button?filter=5&rate=5#postform', '%votes%' => $votes));
        $msg .= '
            <p>
                <strong><a href="https://wordpress.org/support/view/plugin-reviews/likebtn-like-button?filter=5&rate=5#postform" target="_blank">' . __('Give 5 stars', LIKEBTN_I18N_DOMAIN) . '</a></strong> | <a href="#" class="likebtn_dismiss_review">' . __('Dismiss this notice', LIKEBTN_I18N_DOMAIN) . '</a>
                
            </p>
            <script type="text/javascript">
                jQuery(document).ready(function() {
                    jQuery(document).on("click", ".likebtn_review_notice .notice-dismiss, .likebtn_review_notice .likebtn_dismiss_review", function(e) {

                        e.preventDefault();
                        jQuery(".likebtn_review_notice").remove();
                        jQuery.ajax({
                            url: ajaxurl,
                            method: "POST",
                            data: {
                                action: "likebtn_dismiss_review",
                                likebtn_review: "' . $likebtn_review . '"
                            }
                        });
                    });
                });
            </script>
        ';
        _likebtn_notice($msg, 'updated is-dismissible likebtn_review_notice');
    }
}
Exemplo n.º 2
0
function likebtn_admin_notices()
{
    $likebtn_admin_notices = get_option('likebtn_admin_notices');
    if (is_array($likebtn_admin_notices) && count($likebtn_admin_notices)) {
        foreach ($likebtn_admin_notices as $notice) {
            $class = 'updated';
            if (!empty($notice['class'])) {
                $class = $notice['class'];
            }
            _likebtn_notice($notice['msg'], $class);
        }
        update_option('likebtn_admin_notices', array());
    }
}