Esempio n. 1
0
 public static function create_lead_object($form)
 {
     $lead = array();
     $lead['id'] = -1;
     $lead['form_id'] = $form['id'];
     foreach ($form["fields"] as $field) {
         //Ignore fields that are marked as display only
         if (gwget('displayOnly', $field) && $field['type'] != 'password') {
             continue;
         }
         //only save fields that are not hidden (except on entry screen)
         if (!RGFormsModel::is_field_hidden($form, $field, array())) {
             if (isset($field['inputs']) && is_array($field['inputs'])) {
                 foreach ($field['inputs'] as $input) {
                     $lead[(string) $input['id']] = self::get_input_value($form, $field, $lead, $input['id']);
                 }
             } else {
                 $lead[$field['id']] = self::get_input_value($form, $field, $lead, $field['id']);
             }
         }
     }
     return $lead;
 }
Esempio n. 2
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>";
 }
 /**
  * Provides download package when installing and information on the "View version x.x details" page.
  *
  * @uses api_request()
  *
  * @param mixed $_data
  * @param string $_action
  * @param object $_args
  * @return object $_data
  */
 public function perks_plugins_api_filter($_data, $_action = '', $_args = null)
 {
     GravityPerks::log_debug('perks_plugins_api_filter() start. Retrieves download package and plugin info.');
     $plugin_file = isset($_args->slug) ? $_args->slug : gwget('plugin');
     if (strpos($plugin_file, '/') === false) {
         $plugin_file = sprintf('%1$s/%1$s.php', $plugin_file);
     }
     $is_perk = gwget('from') == 'gwp';
     if (!$is_perk) {
         $is_perk = GWPerk::is_perk($plugin_file);
     }
     GravityPerks::log_debug(print_r(compact('slug', 'is_perk'), true));
     if ($_action != 'plugin_information' || !$is_perk || !$plugin_file) {
         return $_data;
     }
     GravityPerks::log_debug('Yes! This is a perk.');
     $api_params = self::get_api_args(array('edd_action' => 'get_perk', 'plugin_file' => $plugin_file, 'license' => $this->license_key));
     $request_args = self::get_request_args(array('body' => urlencode_deep($api_params)));
     $request = wp_remote_post(GW_STORE_URL, $request_args);
     GravityPerks::log_debug('API Parameters: ' . print_r($api_params, true));
     GravityPerks::log_debug('Request Arguments: ' . print_r($request_args, true));
     GravityPerks::log_debug('Response from GW API: ' . print_r($request, true));
     if (is_wp_error($request)) {
         GravityPerks::log_debug('Rats! There was an error with the GW API response');
         return $_data;
     }
     $request = json_decode(wp_remote_retrieve_body($request));
     if (!$request) {
         GravityPerks::log_debug('Rats! There was an error with the GW API response');
         return $_data;
     }
     GravityPerks::log_debug('Ok! Everything looks good. Let\'s build the response needed for WordPress.');
     $request->is_perk = true;
     $request->sections = (array) maybe_unserialize($request->sections);
     $request->sections['changelog'] = GWPerks::format_changelog($request->sections['changelog']);
     // don't allow other plugins to override the $request this function returns, several plugins use the 'plugins_api'
     // filter incorrectly and return a hard 'false' rather than returning the $_data object when they do not need to modify
     // the request which results in our customized $request being overwritten (WPMU Dev Dashboard v3.3.2 is one example)
     remove_all_filters('plugins_api');
     // remove all the filters causes an infinite loop so add one dummy function so the loop can break itself
     add_filter('plugins_api', create_function('$_data', 'return $_data;'));
     // needed for testing on local
     add_filter('http_request_args', array($this, 'allow_unsecure_urls_on_localhost'));
     return $request;
 }
 private static function get_current_page()
 {
     return $current_page = trim(strtolower(gwget('page')));
 }
 function prepare_items()
 {
     $perks = GWPerks::get_perks_listing();
     $this->is_valid_key = GWPerks::has_valid_key();
     if (!is_array($perks)) {
         $this->items = array();
         return;
     }
     $items = array();
     $total = count($perks);
     $page = gwget('paged') ? gwget('paged') : 1;
     $per_page = 10;
     $offset = $page * $per_page - $per_page;
     $cap = $total > $offset + $per_page ? $offset + $per_page : $total;
     for ($i = $offset; $i < $cap; $i++) {
         $items[$perks[$i]['slug']] = array('title' => $this->get_column_title($perks[$i]), 'description' => $perks[$i]['description'], 'slug' => $perks[$i]['slug'], 'version' => $perks[$i]['version']);
     }
     $this->items = $items;
     $this->set_pagination_args(array('total_items' => $total, 'per_page' => $per_page));
 }
Esempio n. 6
0
 function is_entry_detail_edit()
 {
     return IS_ADMIN && gwget('page') == 'gf_entries' && gwget('view') == 'entry' && rgpost('screen_mode');
 }
    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 
    }