Plugin Directory

Changeset 1940701


Ignore:
Timestamp:
09/13/2018 12:55:41 PM (7 years ago)
Author:
zaus
Message:

v0.3 with more functions: param, page_url_domain, network url, time & date (+local), sitename, etc; screenshot

Location:
gf-dynamic-fields/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • gf-dynamic-fields/trunk/README.md

    r1938078 r1940701  
    2525    * `session_desiredkey` where 'session_' is a prefix indicating you want a Session value and 'desiredkey' is the index of which Session value to retrieve
    2626    * `cookie_desiredkey` where 'cookie_' is a prefix indicating you want a Cookie value and 'desiredkey' is the index of which Cookie value to retrieve
     27    * `param_desiredkey` where 'param_' is a prefix indicating that you want a URL query parameter (or form POST) and 'desiredkey' is the index of the request parameter to retrieve.  Gravity Forms actually already does this, but it's included for consistency and this `param` will also check for POST parameters.
    2728    * `page_url` gets the current WP page url
    2829    * `page_url_nodomain` gets the current WP page url without the site domain (i.e. relative path)
     30    * `page_url_domain` gets the domain of the current WP page url without the relative path
     31    * `page_url_network` gets the network domain of the current WP page (useful with multisite); may be the same as `page_url_domain`
    2932    * `page_referer` attempts to get the current referring url
    30     * `page_request` gets the server-generated page url (which may/not be the same as `page_url`)
     33    * `page_request` gets the server-generated page url (which may/not be the same as `page_url`, such as containing the querystring)
    3134    * `page_ip` attempts to get the client's ip address
     35    * `time` gets the current timestamp
     36    * `date` gets the current ISO formatted date
     37    * `time_local` gets the current timestamp formatted to your local settings
     38    * `date_local` gets the current date formatted to your local settings
     39    * `sitename` gets the blog's name as configured in your admin settings
    3240
    3341
    3442## Frequently Asked Questions ##
     43
     44### How does Gravity Forms dynamically populate normally? ###
     45
     46See their wiki page for it -- https://docs.gravityforms.com/using-dynamic-population/
    3547
    3648### How do I get a session value? ###
     
    4254See the installation instructions and use `cookie_yourdesiredkey` as the Parameter Name, where `yourdesiredkey` is the Cookie index you want.
    4355
     56### How do I get a url querystring value? ###
     57
     58Use native GF functionality, or see the installation instructions and use `param_yourdesiredkey` as the Parameter Name, where `yourdesiredkey` is the querystring index you want.
     59
    4460### It doesn't work right... ###
    4561
     
    4864## Screenshots ##
    4965
    50 N/A.
     661. Configuring Gravity Forms advanced field setting 'allow field to be populated dynamically'
    5167
    5268## Changelog ##
     69
     70### 0.3 ###
     71
     72- added URL just domain
     73- added time and date
     74- added sitename
     75- added querystring parameters
     76- added other stuff, see installation
     77- basically almost parity with [Forms 3rdparty Dynamic Fields](https://wordpress.org/plugins/forms-3rdparty-dynamic-fields/) plugin.
    5378
    5479### 0.2 ###
  • gf-dynamic-fields/trunk/gravity-forms-dynamic-fields.php

    r1938074 r1940701  
    66Description: Dynamically fill fields with session, cookie, or other values, based on 'Forms: 3rdparty Dynamic Fields'
    77Author: zaus
    8 Version: 0.2
     8Version: 0.3
    99Author URI: http://drzaus.com
    1010Changelog:
    1111    0.1 initial
    1212    0.2 url without domain
     13    0.3 url just domain, other parity with F3P Dynamic Fields
    1314*/
    1415
     
    2122    const COOKIE_PREFIX = 'cookie';
    2223    const PAGE_PREFIX = 'page';
     24    const PARAM_PREFIX = 'param';
     25
     26    const TIMESTAMP = 'time';
     27    const DATE = 'date';
     28    const DATE_I18N = 'date_local';
     29    const TIME_I18N = 'time_local';
     30    const SITENAME = 'sitename';
    2331
    2432    const PAGE_URL = 'url';
    2533    const PAGE_URL_NODOMAIN = 'url_nodomain';
     34    const PAGE_DOMAIN = 'url_domain';
     35    const PAGE_NETWORK_URL = 'url_network';
    2636    const PAGE_REFERER = 'referer';
    2737    const PAGE_REQUESTURL = 'request';
     
    5060        ## _log(__CLASS__, $value, $name);
    5161
     62        switch($name) {
     63            case self::TIMESTAMP:
     64                return time();
     65            case self::DATE:
     66                return date('c'); // ISO 8601 = Y-m-d\TH:i:sP (PHP5)
     67            case self::DATE_I18N:
     68                return date_i18n( get_option('date_format'), time() );
     69            case self::TIME_I18N:
     70                return date_i18n( get_option('time_format'), time() );
     71            case self::SITENAME:
     72                return get_bloginfo('name');
     73
     74        }
     75
    5276        $prefix = self::PAGE_PREFIX;
    5377        if(strpos($name, $prefix) === 0) {
    5478            $key = substr($name, strlen($prefix)+1);
    5579
    56             switch($key) {
     80            switch($key) { 
    5781                case self::PAGE_URL: return get_permalink();
     82                case self::PAGE_DOMAIN: return get_site_url();
     83                case self::PAGE_NETWORK_URL: return network_site_url();
    5884                case self::PAGE_URL_NODOMAIN: return str_replace(get_site_url(), '', get_permalink());
    5985                case self::PAGE_REFERER: return wp_get_referer();
     
    91117        }
    92118
     119        $prefix = self::PARAM_PREFIX;
     120        if(strpos($name, $prefix) === 0) {
     121            $key = substr($name, strlen($prefix)+1);
     122
     123            return isset($_REQUEST[ $key ]) ? $_REQUEST[ $key ] : $value;
     124        }
     125
    93126        return $value;
    94127    }
  • gf-dynamic-fields/trunk/readme.txt

    r1938078 r1940701  
    2525    * `session_desiredkey` where 'session_' is a prefix indicating you want a Session value and 'desiredkey' is the index of which Session value to retrieve
    2626    * `cookie_desiredkey` where 'cookie_' is a prefix indicating you want a Cookie value and 'desiredkey' is the index of which Cookie value to retrieve
     27    * `param_desiredkey` where 'param_' is a prefix indicating that you want a URL query parameter (or form POST) and 'desiredkey' is the index of the request parameter to retrieve.  Gravity Forms actually already does this, but it's included for consistency and this `param` will also check for POST parameters.
    2728    * `page_url` gets the current WP page url
    2829    * `page_url_nodomain` gets the current WP page url without the site domain (i.e. relative path)
     30    * `page_url_domain` gets the domain of the current WP page url without the relative path
     31    * `page_url_network` gets the network domain of the current WP page (useful with multisite); may be the same as `page_url_domain`
    2932    * `page_referer` attempts to get the current referring url
    30     * `page_request` gets the server-generated page url (which may/not be the same as `page_url`)
     33    * `page_request` gets the server-generated page url (which may/not be the same as `page_url`, such as containing the querystring)
    3134    * `page_ip` attempts to get the client's ip address
     35    * `time` gets the current timestamp
     36    * `date` gets the current ISO formatted date
     37    * `time_local` gets the current timestamp formatted to your local settings
     38    * `date_local` gets the current date formatted to your local settings
     39    * `sitename` gets the blog's name as configured in your admin settings
    3240
    3341
    3442== Frequently Asked Questions ==
     43
     44= How does Gravity Forms dynamically populate normally? =
     45
     46See their wiki page for it -- https://docs.gravityforms.com/using-dynamic-population/
    3547
    3648= How do I get a session value? =
     
    4254See the installation instructions and use `cookie_yourdesiredkey` as the Parameter Name, where `yourdesiredkey` is the Cookie index you want.
    4355
     56### How do I get a url querystring value? ###
     57
     58Use native GF functionality, or see the installation instructions and use `param_yourdesiredkey` as the Parameter Name, where `yourdesiredkey` is the querystring index you want.
     59
    4460= It doesn't work right... =
    4561
     
    4864== Screenshots ==
    4965
    50 N/A.
     661. Configuring Gravity Forms advanced field setting 'allow field to be populated dynamically'
    5167
    5268== Changelog ==
     69
     70= 0.3 =
     71
     72- added URL just domain
     73- added time and date
     74- added sitename
     75- added querystring parameters
     76- added other stuff, see installation
     77- basically almost parity with [Forms 3rdparty Dynamic Fields](https://wordpress.org/plugins/forms-3rdparty-dynamic-fields/) plugin.
    5378
    5479= 0.2 =
Note: See TracChangeset for help on using the changeset viewer.