Plugin Directory

Changeset 2069704


Ignore:
Timestamp:
04/17/2019 04:10:39 AM (7 years ago)
Author:
dunar21
Message:

Added hoot to modify args sent to add_meta_box

Location:
wpr-admin-amplify/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • wpr-admin-amplify/trunk/functions.php

    r1981664 r2069704  
    55Plugin URI: http://worldpressrevolution.com
    66Description: User interface for creating custom posty types, custom fields, custom admin pages, forms ect...
    7 Version: 1.2.1
     7Version: 1.3.0
    88Author: Aryan Duntley
    99Author URI: http://worldpressrevolution.com
     
    350350                'label' => '',
    351351                'description' => '',
    352                 'default_value' => '<div style="background: #EFEFEF"><p><ul style="list-style-type:disc;"><li><pre style="margin: 0px;padding: 0px;display: inline-block;background:#fff;">apply_filters("wpr_postmeta_argsedit", $margs);</pre><br/>You can send a custom array of data available throughout the class<ol><li>$margs are any custom arguments passed (which should be none, the UI does not use this).</li></ol></li><li><pre style="margin: 0px;padding: 0px;display: inline-block;background:#fff;">apply_filters("wpr_postmeta_myownthing", true, $this->pagesadded_met, $post, $xargs);</pre><br/>Executed at the beginning of the callback for add_meta_box().<ol><li>@p1 bool: representing whether to continue executing code from this point on.  If false, nothing will happen after this point and code will rely on whatever you do here.</li><li>@p2 array: is array of all data sent to the class including all field data for the meta box.</li><li>@p3 global post object.</li><li>@p4 array: any custom arguments that were sent to the class or hooked.</li></ol></li><li><pre style="margin: 0px;padding: 0px;display: inline-block;background:#fff;">do_action("wpr_postmeta_myfield", $post_ob_name, $value, $metabox, $post, $this->pagesadded_met, $xargs);</pre><br/>A switch statement is used to traverse through the various field types.  The default field type is blank and this hook is placed there.  You can create your own field types using this hook along with the "wpr_postmeta_saving_call" if needed.<ol><li>@p1 string: is the post name that will be sent via http post when the form is saved. It is consists of the general post name and the key ie "postname[keyid]" wher keyid is the id of the field you created.</li><li>@p2 array: This is not named very well, but oh well.  This is actually the string indexed array of all the field parameters (id, title, name, desc, std, etc...) .</li><li>@p3 string|array: This is the value of the meta field, or the $value["std"] (default value) if the meta field has not yet been created.</li><li>@p4 The global post object.</li><li>@p5 array: All the class variables</li><li>@p6 array: any custom array data set by you.</li></ol></li><li><pre style="margin: 0px;padding: 0px;display: inline-block;background:#fff;">do_action("wpr_postmeta_afterfield", $post_ob_name, $value, $metabox, $post, $this->pagesadded_met, $xargs);</pre><br/>This is called after the field has been created.  Do whatever you want here. <ol><li>Exact same params as "wpr_postmeta_myfield" above.</li></ol></li><li><pre style="margin: 0px;padding: 0px;display: inline-block;background:#fff;">do_action("wpr_postmeta_afterfields", $post_ob_name, $post, $this->pagesadded_met, $xargs);</pre><br/>This is called after all fields have been created.<ol><li>@p1 string: post name (same as above two)</li><li>$p2 global post object</li><li>@p3 array: class params same as above two</li><li>@p4 array: additional args same as above 2.</li></ol></li><li><pre style="margin: 0px;padding: 0px;display: inline-block;background:#fff;">apply_filters("wpr_postmeta_saving_call", true, $_POST[$this->pagesadded_met["postnm"]], $this->pagesadded_met, $post_id);</pre><br/>This is called right after the post has been saved. You can let the typical saving do it\'s thing or you can do your own thing then let the code run, or you can do you own thing and stop the code from running. Return true to continue running the rest of the saving code, return false if you have done your own thing in the hook and do not want the code to continue running.  You should test the params to make sure that you are grabbing the correct stuff.  This hook can prevent any meta fields from getting saved at all so use carefully.<ol><li>@p1 bool: continue with following code or no.</li><li>@p2 array: the entire posted array from the save post form.</li><li>@p3 array: the class params</li><li>@p4 int: the post id.</li></ol></li><li><pre style="margin: 0px;padding: 0px;display: inline-block;background:#fff;">apply_filters("wpr_postmeta_saving_one", true, $post_id, $dpname, $dpval, $_POST[$this->pagesadded_met["postnm"]], $this->pagesadded_met);</pre><br/>This is within a loop that iterates through the post array from the form.  You can control individual post elements here.  Return true to run the rest of the code (update_post_meta()) or false to not.<ol><li>@p1 bool: whether to continue with updating the post meta for this particular meta field.</li><li>@p2 int: the post id.</li><li>@p3 string: the post name.</li><li>@p4 string: the post value.</li><li>@p5 array: the entire meta post array from the form (only meta box fields part of it)</li><li>@p6 array: the class params</li></ol></li></ul></p></div>',
     352                'default_value' => '<div style="background: #EFEFEF"><p><ul style="list-style-type:disc;">
     353                <li><pre style="margin: 0px;padding: 0px;display: inline-block;background:#fff;">apply_filters("wpr_postmeta_fullargsedit", $this->pagesadded_met);</pre><br/>You can modify the array of values sent to the add metabox function<ol><li>$this->pagesadded_met is an array of data describing the meta box.</li><li><pre>function customFilterArgsXYZ($args){<br/>for($i=0;$i<count($args["fields"]);$i++){<br/>if($args["fields"][$i]["id"] == "sponsorthiseventdesc"){/* This is the id you set when creating the custom meta box */<br/>$args["fields"][$i]["std"] = $def;/* default value */<br/>$args["fields"][$i]["placeholder"] = $def;/* placeholder */<br/>$args["fields"][$i]["title"] = $def;/* title */<br/>$args["fields"][$i]["desc"] = $def;/* description */<br/>/* any other fields should probably not be modified, you could break the functionality of saving the data */<br/>}<br/>}<br/>return $args;<br/>}<br/>add_filter("wpr_postmeta_fullargsedit", "customFilterArgsXYZ", 10);</pre></li></ol></li><li><pre style="margin: 0px;padding: 0px;display: inline-block;background:#fff;">apply_filters("wpr_postmeta_argsedit", $margs);</pre><br/>You can send a custom array of data available throughout the class<ol><li>$margs are any custom arguments passed (which should be none, the UI does not use this).</li></ol></li><li><pre style="margin: 0px;padding: 0px;display: inline-block;background:#fff;">apply_filters("wpr_postmeta_myownthing", true, $this->pagesadded_met, $post, $xargs);</pre><br/>Executed at the beginning of the callback for add_meta_box().<ol><li>@p1 bool: representing whether to continue executing code from this point on.  If false, nothing will happen after this point and code will rely on whatever you do here.</li><li>@p2 array: is array of all data sent to the class including all field data for the meta box.</li><li>@p3 global post object.</li><li>@p4 array: any custom arguments that were sent to the class or hooked.</li></ol></li><li><pre style="margin: 0px;padding: 0px;display: inline-block;background:#fff;">do_action("wpr_postmeta_myfield", $post_ob_name, $value, $metabox, $post, $this->pagesadded_met, $xargs);</pre><br/>A switch statement is used to traverse through the various field types.  The default field type is blank and this hook is placed there.  You can create your own field types using this hook along with the "wpr_postmeta_saving_call" if needed.<ol><li>@p1 string: is the post name that will be sent via http post when the form is saved. It is consists of the general post name and the key ie "postname[keyid]" wher keyid is the id of the field you created.</li><li>@p2 array: This is not named very well, but oh well.  This is actually the string indexed array of all the field parameters (id, title, name, desc, std, etc...) .</li><li>@p3 string|array: This is the value of the meta field, or the $value["std"] (default value) if the meta field has not yet been created.</li><li>@p4 The global post object.</li><li>@p5 array: All the class variables</li><li>@p6 array: any custom array data set by you.</li></ol></li><li><pre style="margin: 0px;padding: 0px;display: inline-block;background:#fff;">do_action("wpr_postmeta_afterfield", $post_ob_name, $value, $metabox, $post, $this->pagesadded_met, $xargs);</pre><br/>This is called after the field has been created.  Do whatever you want here. <ol><li>Exact same params as "wpr_postmeta_myfield" above.</li></ol></li><li><pre style="margin: 0px;padding: 0px;display: inline-block;background:#fff;">do_action("wpr_postmeta_afterfields", $post_ob_name, $post, $this->pagesadded_met, $xargs);</pre><br/>This is called after all fields have been created.<ol><li>@p1 string: post name (same as above two)</li><li>$p2 global post object</li><li>@p3 array: class params same as above two</li><li>@p4 array: additional args same as above 2.</li></ol></li><li><pre style="margin: 0px;padding: 0px;display: inline-block;background:#fff;">apply_filters("wpr_postmeta_saving_call", true, $_POST[$this->pagesadded_met["postnm"]], $this->pagesadded_met, $post_id);</pre><br/>This is called right after the post has been saved. You can let the typical saving do it\'s thing or you can do your own thing then let the code run, or you can do you own thing and stop the code from running. Return true to continue running the rest of the saving code, return false if you have done your own thing in the hook and do not want the code to continue running.  You should test the params to make sure that you are grabbing the correct stuff.  This hook can prevent any meta fields from getting saved at all so use carefully.<ol><li>@p1 bool: continue with following code or no.</li><li>@p2 array: the entire posted array from the save post form.</li><li>@p3 array: the class params</li><li>@p4 int: the post id.</li></ol></li><li><pre style="margin: 0px;padding: 0px;display: inline-block;background:#fff;">apply_filters("wpr_postmeta_saving_one", true, $post_id, $dpname, $dpval, $_POST[$this->pagesadded_met["postnm"]], $this->pagesadded_met);</pre><br/>This is within a loop that iterates through the post array from the form.  You can control individual post elements here.  Return true to run the rest of the code (update_post_meta()) or false to not.<ol><li>@p1 bool: whether to continue with updating the post meta for this particular meta field.</li><li>@p2 int: the post id.</li><li>@p3 string: the post name.</li><li>@p4 string: the post value.</li><li>@p5 array: the entire meta post array from the form (only meta box fields part of it)</li><li>@p6 array: the class params</li></ol></li></ul></p></div>',
    353354            ),
    354355        )
  • wpr-admin-amplify/trunk/postmeta.php

    r1151615 r2069704  
    2020        'fields' => $fields,
    2121    );
     22        $this->pagesadded_met = apply_filters('wpr_postmeta_fullargsedit', $this->pagesadded_met);
    2223        $this->pagesadded_met['xargs'] = apply_filters('wpr_postmeta_argsedit', $margs);
    2324        add_action('admin_menu',  array( $this, 'add_paga_metabox'));
     
    209210                    </div>
    210211                    <div style="float:left;width:75%;">
    211                         <input id="<?php echo $value['id']; ?>" class="met_<?php echo $value['type']; ?>" type="text" size="120" name="<?php echo $postarr . '[' . $value['id'] . ']'; ?>" value="<?php echo $metabox; ?>" <?php if($value['decimal'] && $value['decimal'] == 'true'){ ?>onkeyup="if(/\D/g.test(this.value)){this.value = this.value.replace(/\D/g,'');}" <?php } ?> placeholder="<?php echo isset($field["placeholder"])?$field["placeholder"]:""; ?>"/>
     212                        <input id="<?php echo $value['id']; ?>" class="met_<?php echo $value['type']; ?>" type="text" size="120" name="<?php echo $postarr . '[' . $value['id'] . ']'; ?>" value="<?php echo $metabox; ?>" <?php if($value['decimal'] && $value['decimal'] == 'true'){ ?>onkeyup="if(/\D/g.test(this.value)){this.value = this.value.replace(/\D/g,'');}" <?php } ?> placeholder="<?php echo isset($value["placeholder"])?$value["placeholder"]:""; ?>"/>
    212213                    </div>
    213214                    <br class="clear" />
     
    239240                ?>
    240241                <div class="metabox" style="display:block;width:100%;padding:10px;">
    241                     <div class="text" style="float:left;width:70%;">
    242                         <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
    243                         <p class="description"><?php echo $value['desc']; ?></p>
    244                     </div>
    245                     <div style="float:left;width:75%;">
     242                    <div class="chck" style="float:left; margin-right: 10px">
     243                        <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
     244                        <p class="description"><?php echo $value['desc']; ?></p>
     245                    </div>
     246                    <div style="display: inline-block; position: relative; top: 5px;">
    246247                        <input class="checkersbox" type="checkbox" value="<?php echo $metabox; ?>" data-on="<?php echo $dars[1]; ?>" data-off="<?php echo $dars[2]; ?>" <?php echo $ischk; ?> >
    247248                        <input id="<?php echo $value['id']; ?>" class="met_<?php echo $value['type']; ?> checkshadow" type="hidden" name="<?php echo $postarr . '[' . $value['id'] . ']'; ?>" value="<?php echo $metabox; ?>" />
     
    357358                    </div>
    358359                    <div style="float:left;width:90%;">
    359                         <textarea id="<?php echo $value['id']; ?>" class="<?php echo $value['id']; ?>" type="text" name="<?php echo $postarr . '[' . $value['id'] . ']'; ?>" placeholder="<?php echo isset($field["placeholder"])?$field["placeholder"]:""; ?>"><?php echo $metabox; ?></textarea>
     360                        <textarea id="<?php echo $value['id']; ?>" class="<?php echo $value['id']; ?>" type="text" name="<?php echo $postarr . '[' . $value['id'] . ']'; ?>" placeholder="<?php echo isset($value["placeholder"])?$value["placeholder"]:""; ?>"><?php echo $metabox; ?></textarea>
    360361                    </div>
    361362                    <br class="clear" />
  • wpr-admin-amplify/trunk/readme.txt

    r1981664 r2069704  
    77Tags: membership, restricted content, protected content, custom post type, custom options page, custom fields, custom taxonomy, custom categories, custom post meta, custom forms,
    88Requires at least: 3.0.1
    9 Tested up to: 4.9.8
    10 Stable tag: 1.2.1
     9Tested up to: 5.1.1
     10Stable tag: 1.3.0
    1111License: GPLv2 or later
    1212License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    127127* Fixed a bug.
    128128
     129= 1.3.0 =
     130
     131* Aded a new hook allowing control of args sent to create meta box
    129132
    130133
Note: See TracChangeset for help on using the changeset viewer.