示例#1
0
 public static function handle_message_code()
 {
     $message_code = gwget('message');
     if (!$message_code) {
         return;
     }
     $message = gwar(GWPerks::$message_codes, $message_code);
     echo "<div id=\"message\" class=\"updated below-h2\"><p>{$message}</p></div>";
 }
示例#2
0
 /**
  * Get perk setting, will automatically append the perk slug.
  *
  * @param mixed $key
  * @param mixed $settings
  */
 function get_setting($key, $settings = array())
 {
     if (empty($settings)) {
         $settings = GWPerk::get_perk_settings($this->get_id());
     }
     return gwar($settings, $this->get_id() . "_{$key}");
 }
 public static function require_gravity_perks_network_activation()
 {
     if (!is_network_admin() || !self::is_last_modified_plugin_perk() || self::is_gravity_perks_network_activated()) {
         return;
     }
     $plugin = gwar($_REQUEST, 'plugin');
     $redirect = self_admin_url('plugins.php?gwp_error=networkperks&plugin=' . $plugin);
     wp_redirect(esc_url_raw(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)));
     exit;
 }
    function column_default($item, $column_name)
    {
        switch ($column_name) {
            case 'description':
                ?>

            <div class="plugin-description">
                <p><?php 
                echo gwar($item, $column_name);
                ?>
</p>
            </div>

            <div class="second plugin-version-author-uri">

                <?php 
                $perk_meta = array();
                if (gwar($item, 'version')) {
                    $perk_meta[] = sprintf(__('Version %s', 'gravityperks'), $item['version']);
                }
                if (gwar($item, 'author')) {
                    $author = gwar($item, 'author') ? "<a href=\"{$item['authoruri']}\">{$item['author']}</a>" : $item['author'];
                    $perk_meta[] = sprintf(__('By %s', 'gravityperks'), $author);
                }
                if (gwar($item, 'snippeturi')) {
                    $perk_meta[] = '<a href="' . $item['snippeturi'] . '" title="' . esc_attr__('Visit perk site', 'gravityperks') . '">' . __('Visit perk site', 'gravityperks') . '</a>';
                }
                echo implode(' | ', $perk_meta);
                ?>

            </div>

            <?php 
                break;
            default:
                echo gwar($item, $column_name);
        }
    }
示例#5
0
 /**
  * Check if the passed field is the same type as this GWField object.
  *
  * @param array $field
  */
 function is_this_field_type($field)
 {
     return gwar($field, 'type') == $this->type;
 }
    public static function settings_page()
    {
        $settings = get_site_option('gwp_settings') ? get_site_option('gwp_settings') : array();
        $is_submit = gwpost('gwp_settings_submit') == true;
        if (gwpost('uninstall')) {
            // uninstall functionality...
        } else {
            if (gwpost('gwp_settings_submit')) {
                check_admin_referer('update', 'gwp_settings');
                $new_license = trim(stripslashes(gwpost('gwp_license_key')));
                $old_license = trim(gwar($settings, 'license_key'));
                $is_diff_license = $new_license != $old_license;
                $settings = array_merge($settings, array('license_key' => trim(stripslashes($_POST['gwp_license_key']))));
                update_site_option('gwp_settings', $settings);
                // if a different license is entered, delete the 'gwp_has_valid_license' transient so the next 'has_valid_license'
                // check will do a fresh check to confirm new licenses' validity
                if ($is_diff_license) {
                    GWPerks::flush_license();
                }
            }
        }
        $is_license_valid = gwar($settings, 'license_key') && GWPerks::has_valid_license();
        ?>

        <?php 
        if ($is_submit && gwget('register') && $is_license_valid) {
            ?>
            <div class="updated"><p>
                <?php 
            printf(__('Awesome! Your now have unlimited access to <strong>all perks</strong> with automatic upgrades and support. %sLet\'s go install some perks!%s', 'gravityperks'), '<a href="' . GW_MANAGE_PERKS_URL . '&view=install">', '</a>');
            ?>
            </p></div>
        <?php 
        } elseif ($is_submit && !$is_license_valid) {
            ?>
            <div class="error"><p>
                <?php 
            _e('Oops! That doesn\'t appear to be a valid license.', 'gravityperks');
            ?>
            </p></div>
        <?php 
        }
        ?>

        <style type="text/css">
            .gform_tab_content input,
            .gform_tab_content textarea {
                outline-style: none;
                font-family: inherit;
                font-size: inherit;
                padding: 3px 5px;
            }
        </style>

        <form method="post" action="">

            <?php 
        wp_nonce_field('update', 'gwp_settings');
        ?>

            <h3><?php 
        _e('Gravity Perks Settings', 'gravityperks');
        ?>
</h3>

            <table class="form-table">
                <tr>
                    <th scope="row"><label for="gwp_license_key"><?php 
        _e('Gravity Perks License Key', 'gravityperks');
        ?>
</label></th>
                    <td>
                        <input type="password" id="gwp_license_key" name="gwp_license_key" value="<?php 
        echo !gwar($settings, 'license_key') ? '' : trim(esc_attr(gwar($settings, 'license_key')));
        ?>
" size="50" />
                        <?php 
        if (gwar($settings, 'license_key')) {
            if ($is_license_valid) {
                ?>

                                <?php 
                if (!version_compare(GFCommon::$version, '1.8', '>=')) {
                    ?>
                                    <img src="<?php 
                    echo GFCommon::get_base_url();
                    ?>
/images/tick.png" style="position:relative;top:2px" />
                                <?php 
                } else {
                    ?>
                                    <i class="fa fa-check gf_keystatus_valid"></i>
                                <?php 
                }
                ?>

                            <?php 
            } else {
                ?>

                                <?php 
                if (!version_compare(GFCommon::$version, '1.8', '>=')) {
                    ?>
                                    <img src="<?php 
                    echo GFCommon::get_base_url();
                    ?>
/images/cross.png" style="position:relative;top:2px" />
                                <?php 
                } else {
                    ?>
                                    <i class="fa fa-times gf_keystatus_invalid"></i>
                                <?php 
                }
                ?>

                            <?php 
            }
        }
        ?>

                        <p class="description" style="padding-top:0;">
                            <?php 
        if (!$is_license_valid) {
            ?>
                                <?php 
            _e('Register your copy of Gravity Perks for unlimited access to all perks, automatic upgrades and support!', 'gravityperks');
            ?>
                            <?php 
        } else {
            ?>
                                <?php 
            _e('Awesome! You have unlimited access to <strong>all perks</strong> with automatic upgrades and support.', 'gravityperks');
            ?>
                            <?php 
        }
        ?>
                        </p>

                    </td>
                </tr>
                <tr>
                    <td colspan="2" >
                        <input type="submit" name="gwp_settings_submit" class="button-primary" value="<?php 
        _e('Save Settings', 'gravityperks');
        ?>
" />
                    </td>
                </tr>
            </table>

        </form>

        <?php 
    }