WordPress.org

Plugin Directory

Changeset 749179


Ignore:
Timestamp:
08/01/13 09:38:57 (9 months ago)
Author:
eskapism
Message:

version 1.4.2

Location:
simple-fields
Files:
2 edited
29 copied

Legend:

Unmodified
Added
Removed
  • simple-fields/tags/1.4.2/readme.txt

    r741297 r749179  
    55Requires at least: 3.5.1 
    66Tested up to: 3.5.1 
    7 Stable tag: 1.4.1 
     7Stable tag: 1.4.2 
    88 
    99With Simple Fields you can add any kind of custom fields to your pages, posts and attachments. 
     
    144144 
    145145== Changelog == 
     146 
     147#### Version 1.4.2 
     148- Post Connectors can now be set from within a page template. Just add 
     149Simple Fields Connector: slugOfPostConnector 
     150to your template and that connector will be used for all pages with that template. 
     151- New filters as a result from above: set_post_connector_from_template, get_post_connector_from_template 
    146152 
    147153#### Version 1.4.1 
  • simple-fields/tags/1.4.2/simple_fields.php

    r741297 r749179  
    44Plugin URI: http://simple-fields.com 
    55Description: Add groups of textareas, input-fields, dropdowns, radiobuttons, checkboxes and files to your edit post screen. 
    6 Version: 1.4.1 
     6Version: 1.4.2 
    77Author: Pär Thernström 
    88Author URI: http://eskapism.se/ 
     
    5858 
    5959 
    60         define( "SIMPLE_FIELDS_VERSION", "1.4.1"); 
     60        define( "SIMPLE_FIELDS_VERSION", "1.4.2"); 
    6161        define( "SIMPLE_FIELDS_URL", plugins_url(basename(dirname(__FILE__))). "/"); 
    6262        define( "SIMPLE_FIELDS_NAME", "Simple Fields"); 
     
    108108        add_action( 'save_post', array($this, 'clear_caches') ); 
    109109        add_action( 'edit_attachment', array($this, 'save_postdata') ); 
     110        add_action( "simple_fields_get_selected_connector_for_post", array($this, "set_post_connector_from_template"), 10, 2 ); 
    110111 
    111112        // Query filters 
     
    22192220            } 
    22202221        } 
    2221          
     2222 
    22222223        ?> 
    22232224        <div class="inside"> 
    2224             <div> 
    2225                 <select name="simple_fields_selected_connector" id="simple-fields-post-edit-side-field-settings-select-connector"> 
    2226                     <option <?php echo ($saved_connector_to_use == "__none__") ? " selected='selected' " : "" ?> value="__none__"><?php _e('None', 'simple-fields') ?></option> 
    2227                     <option <?php echo ($saved_connector_to_use == "__inherit__") ? " selected='selected' " : "" ?> value="__inherit__"><?php _e('Inherit from parent', 'simple-fields') ?> 
    2228                         <?php 
    2229                         echo $str_inherit_parent_connector_name; 
    2230                         ?> 
    2231                     </option> 
    2232                     <?php foreach ($arr_connectors as $one_connector) : ?> 
    2233                         <?php if ($one_connector["deleted"]) { continue; } ?> 
    2234                         <option <?php echo ($saved_connector_to_use == $one_connector["id"]) ? " selected='selected' " : "" ?> value="<?php echo $one_connector["id"] ?>"><?php echo $one_connector["name"] ?></option> 
    2235                     <?php endforeach; ?> 
    2236                 </select> 
    2237             </div> 
     2225 
    22382226            <?php 
    2239             // If connector has been changed with filter then show was connector is being used 
    2240             if ( is_numeric($connector_selected) && $connector_selected != $saved_connector_to_use ) { 
    2241                 $connector_selected_info = $this->get_connector_by_id($connector_selected); 
    2242                 ?><div><p><?php _e("Actual used connector:", "simple-fields") ?> <?php echo $connector_selected_info["name"]; ?></p></div><?php 
    2243             } 
     2227 
     2228            // If connector is set from template then that overrides dropdown 
     2229            if ( $this->post_has_template_connector( $post ) ) { 
     2230             
     2231                $template = !empty($post->page_template) ? $post->page_template : false; 
     2232                $post_connector_from_template = $this->get_post_connector_from_template( $template ); 
     2233                ?> 
     2234                <p><?php _e( sprintf('Post connector is defined in template and is set to "%1$s"', $post_connector_from_template), "simple-fields") ?></p> 
     2235                <?php 
     2236             
     2237            } else { 
     2238 
     2239                // dropdown with post connectors ?> 
     2240                <div> 
     2241                    <select name="simple_fields_selected_connector" id="simple-fields-post-edit-side-field-settings-select-connector"> 
     2242                        <option <?php echo ($saved_connector_to_use == "__none__") ? " selected='selected' " : "" ?> value="__none__"><?php _e('None', 'simple-fields') ?></option> 
     2243                        <option <?php echo ($saved_connector_to_use == "__inherit__") ? " selected='selected' " : "" ?> value="__inherit__"><?php _e('Inherit from parent', 'simple-fields') ?> 
     2244                            <?php 
     2245                            echo $str_inherit_parent_connector_name; 
     2246                            ?> 
     2247                        </option> 
     2248                        <?php foreach ($arr_connectors as $one_connector) : ?> 
     2249                            <?php if ($one_connector["deleted"]) { continue; } ?> 
     2250                            <option <?php echo ($saved_connector_to_use == $one_connector["id"]) ? " selected='selected' " : "" ?> value="<?php echo $one_connector["id"] ?>"><?php echo $one_connector["name"] ?></option> 
     2251                        <?php endforeach; ?> 
     2252                    </select> 
     2253                </div> 
     2254                <?php 
     2255 
     2256                // If connector has been changed with filter then show was connector is being used 
     2257                if ( is_numeric($connector_selected) && $connector_selected != $saved_connector_to_use ) { 
     2258                    $connector_selected_info = $this->get_connector_by_id($connector_selected); 
     2259                    ?><div><p><?php _e("Actual used connector:", "simple-fields") ?> <?php echo $connector_selected_info["name"]; ?></p></div><?php 
     2260                } 
     2261 
     2262                ?> 
     2263                <div id="simple-fields-post-edit-side-field-settings-select-connector-please-save" class="hidden"> 
     2264                    <p><?php _e('Save post to switch to selected fields.', 'simple-fields') ?></p> 
     2265                </div> 
     2266                <?php 
     2267             
     2268            } 
     2269 
    22442270            ?> 
    2245             <div id="simple-fields-post-edit-side-field-settings-select-connector-please-save" class="hidden"> 
    2246                 <p><?php _e('Save post to switch to selected fields.', 'simple-fields') ?></p> 
    2247             </div> 
    22482271            <div> 
    22492272                <p><a href="#" id="simple-fields-post-edit-side-field-settings-show-keys"><?php _e('Show custom field keys', 'simple-fields') ?></a></p> 
     
    44384461    } 
    44394462 
     4463    /** 
     4464     * Look for post connector defined in template 
     4465     * Format in template is: 
     4466     * 
     4467     * Simple Fields Connector: useMeAsThePostConnector 
     4468     * 
     4469     * Hooked into action simple_fields_get_selected_connector_for_post 
     4470     * 
     4471     */ 
     4472    function set_post_connector_from_template($connector_to_use, $post) { 
     4473         
     4474        // Look for connector defined in template 
     4475        $template = !empty($post->page_template) ? $post->page_template : false; 
     4476        $post_connector_from_template = $this->get_post_connector_from_template( $template ); 
     4477        if ($post_connector_from_template) $connector_to_use = $post_connector_from_template; 
     4478 
     4479        $connector_to_use = apply_filters("set_post_connector_from_template", $connector_to_use, $post); 
     4480 
     4481        return $connector_to_use; 
     4482 
     4483    } 
     4484 
     4485    /** 
     4486     * Returns true if post has a template connector defined 
     4487     */ 
     4488    function post_has_template_connector($post) { 
     4489 
     4490        $template = !empty($post->page_template) ? $post->page_template : false; 
     4491        $post_connector_from_template = $this->get_post_connector_from_template( $template ); 
     4492        return (bool) $post_connector_from_template; 
     4493 
     4494    } 
     4495 
     4496 
     4497    /** 
     4498     * @param string $template template filename 
     4499     * @return string Slug of post connector. Empty if no one set 
     4500     */ 
     4501    function get_post_connector_from_template($template) { 
     4502 
     4503        $template_file = locate_template($template); 
     4504        if ( is_file( $template_file ) ) { 
     4505            $template_data = get_file_data( $template_file, array("Name" => "Template Name", "PostConnector" => "Simple Fields Connector") ); 
     4506            $post_connector = trim($template_data["PostConnector"]); 
     4507        } else { 
     4508            $post_connector = ""; 
     4509        } 
     4510         
     4511        $post_connector = apply_filters("get_post_connector_from_template", $post_connector, $template); 
     4512         
     4513        return $post_connector; 
     4514 
     4515    } 
    44404516 
    44414517} // end class 
  • simple-fields/trunk/readme.txt

    r741297 r749179  
    55Requires at least: 3.5.1 
    66Tested up to: 3.5.1 
    7 Stable tag: 1.4.1 
     7Stable tag: 1.4.2 
    88 
    99With Simple Fields you can add any kind of custom fields to your pages, posts and attachments. 
     
    144144 
    145145== Changelog == 
     146 
     147#### Version 1.4.2 
     148- Post Connectors can now be set from within a page template. Just add 
     149Simple Fields Connector: slugOfPostConnector 
     150to your template and that connector will be used for all pages with that template. 
     151- New filters as a result from above: set_post_connector_from_template, get_post_connector_from_template 
    146152 
    147153#### Version 1.4.1 
  • simple-fields/trunk/simple_fields.php

    r741297 r749179  
    44Plugin URI: http://simple-fields.com 
    55Description: Add groups of textareas, input-fields, dropdowns, radiobuttons, checkboxes and files to your edit post screen. 
    6 Version: 1.4.1 
     6Version: 1.4.2 
    77Author: Pär Thernström 
    88Author URI: http://eskapism.se/ 
     
    5858 
    5959 
    60         define( "SIMPLE_FIELDS_VERSION", "1.4.1"); 
     60        define( "SIMPLE_FIELDS_VERSION", "1.4.2"); 
    6161        define( "SIMPLE_FIELDS_URL", plugins_url(basename(dirname(__FILE__))). "/"); 
    6262        define( "SIMPLE_FIELDS_NAME", "Simple Fields"); 
     
    108108        add_action( 'save_post', array($this, 'clear_caches') ); 
    109109        add_action( 'edit_attachment', array($this, 'save_postdata') ); 
     110        add_action( "simple_fields_get_selected_connector_for_post", array($this, "set_post_connector_from_template"), 10, 2 ); 
    110111 
    111112        // Query filters 
     
    22192220            } 
    22202221        } 
    2221          
     2222 
    22222223        ?> 
    22232224        <div class="inside"> 
    2224             <div> 
    2225                 <select name="simple_fields_selected_connector" id="simple-fields-post-edit-side-field-settings-select-connector"> 
    2226                     <option <?php echo ($saved_connector_to_use == "__none__") ? " selected='selected' " : "" ?> value="__none__"><?php _e('None', 'simple-fields') ?></option> 
    2227                     <option <?php echo ($saved_connector_to_use == "__inherit__") ? " selected='selected' " : "" ?> value="__inherit__"><?php _e('Inherit from parent', 'simple-fields') ?> 
    2228                         <?php 
    2229                         echo $str_inherit_parent_connector_name; 
    2230                         ?> 
    2231                     </option> 
    2232                     <?php foreach ($arr_connectors as $one_connector) : ?> 
    2233                         <?php if ($one_connector["deleted"]) { continue; } ?> 
    2234                         <option <?php echo ($saved_connector_to_use == $one_connector["id"]) ? " selected='selected' " : "" ?> value="<?php echo $one_connector["id"] ?>"><?php echo $one_connector["name"] ?></option> 
    2235                     <?php endforeach; ?> 
    2236                 </select> 
    2237             </div> 
     2225 
    22382226            <?php 
    2239             // If connector has been changed with filter then show was connector is being used 
    2240             if ( is_numeric($connector_selected) && $connector_selected != $saved_connector_to_use ) { 
    2241                 $connector_selected_info = $this->get_connector_by_id($connector_selected); 
    2242                 ?><div><p><?php _e("Actual used connector:", "simple-fields") ?> <?php echo $connector_selected_info["name"]; ?></p></div><?php 
    2243             } 
     2227 
     2228            // If connector is set from template then that overrides dropdown 
     2229            if ( $this->post_has_template_connector( $post ) ) { 
     2230             
     2231                $template = !empty($post->page_template) ? $post->page_template : false; 
     2232                $post_connector_from_template = $this->get_post_connector_from_template( $template ); 
     2233                ?> 
     2234                <p><?php _e( sprintf('Post connector is defined in template and is set to "%1$s"', $post_connector_from_template), "simple-fields") ?></p> 
     2235                <?php 
     2236             
     2237            } else { 
     2238 
     2239                // dropdown with post connectors ?> 
     2240                <div> 
     2241                    <select name="simple_fields_selected_connector" id="simple-fields-post-edit-side-field-settings-select-connector"> 
     2242                        <option <?php echo ($saved_connector_to_use == "__none__") ? " selected='selected' " : "" ?> value="__none__"><?php _e('None', 'simple-fields') ?></option> 
     2243                        <option <?php echo ($saved_connector_to_use == "__inherit__") ? " selected='selected' " : "" ?> value="__inherit__"><?php _e('Inherit from parent', 'simple-fields') ?> 
     2244                            <?php 
     2245                            echo $str_inherit_parent_connector_name; 
     2246                            ?> 
     2247                        </option> 
     2248                        <?php foreach ($arr_connectors as $one_connector) : ?> 
     2249                            <?php if ($one_connector["deleted"]) { continue; } ?> 
     2250                            <option <?php echo ($saved_connector_to_use == $one_connector["id"]) ? " selected='selected' " : "" ?> value="<?php echo $one_connector["id"] ?>"><?php echo $one_connector["name"] ?></option> 
     2251                        <?php endforeach; ?> 
     2252                    </select> 
     2253                </div> 
     2254                <?php 
     2255 
     2256                // If connector has been changed with filter then show was connector is being used 
     2257                if ( is_numeric($connector_selected) && $connector_selected != $saved_connector_to_use ) { 
     2258                    $connector_selected_info = $this->get_connector_by_id($connector_selected); 
     2259                    ?><div><p><?php _e("Actual used connector:", "simple-fields") ?> <?php echo $connector_selected_info["name"]; ?></p></div><?php 
     2260                } 
     2261 
     2262                ?> 
     2263                <div id="simple-fields-post-edit-side-field-settings-select-connector-please-save" class="hidden"> 
     2264                    <p><?php _e('Save post to switch to selected fields.', 'simple-fields') ?></p> 
     2265                </div> 
     2266                <?php 
     2267             
     2268            } 
     2269 
    22442270            ?> 
    2245             <div id="simple-fields-post-edit-side-field-settings-select-connector-please-save" class="hidden"> 
    2246                 <p><?php _e('Save post to switch to selected fields.', 'simple-fields') ?></p> 
    2247             </div> 
    22482271            <div> 
    22492272                <p><a href="#" id="simple-fields-post-edit-side-field-settings-show-keys"><?php _e('Show custom field keys', 'simple-fields') ?></a></p> 
     
    44384461    } 
    44394462 
     4463    /** 
     4464     * Look for post connector defined in template 
     4465     * Format in template is: 
     4466     * 
     4467     * Simple Fields Connector: useMeAsThePostConnector 
     4468     * 
     4469     * Hooked into action simple_fields_get_selected_connector_for_post 
     4470     * 
     4471     */ 
     4472    function set_post_connector_from_template($connector_to_use, $post) { 
     4473         
     4474        // Look for connector defined in template 
     4475        $template = !empty($post->page_template) ? $post->page_template : false; 
     4476        $post_connector_from_template = $this->get_post_connector_from_template( $template ); 
     4477        if ($post_connector_from_template) $connector_to_use = $post_connector_from_template; 
     4478 
     4479        $connector_to_use = apply_filters("set_post_connector_from_template", $connector_to_use, $post); 
     4480 
     4481        return $connector_to_use; 
     4482 
     4483    } 
     4484 
     4485    /** 
     4486     * Returns true if post has a template connector defined 
     4487     */ 
     4488    function post_has_template_connector($post) { 
     4489 
     4490        $template = !empty($post->page_template) ? $post->page_template : false; 
     4491        $post_connector_from_template = $this->get_post_connector_from_template( $template ); 
     4492        return (bool) $post_connector_from_template; 
     4493 
     4494    } 
     4495 
     4496 
     4497    /** 
     4498     * @param string $template template filename 
     4499     * @return string Slug of post connector. Empty if no one set 
     4500     */ 
     4501    function get_post_connector_from_template($template) { 
     4502 
     4503        $template_file = locate_template($template); 
     4504        if ( is_file( $template_file ) ) { 
     4505            $template_data = get_file_data( $template_file, array("Name" => "Template Name", "PostConnector" => "Simple Fields Connector") ); 
     4506            $post_connector = trim($template_data["PostConnector"]); 
     4507        } else { 
     4508            $post_connector = ""; 
     4509        } 
     4510         
     4511        $post_connector = apply_filters("get_post_connector_from_template", $post_connector, $template); 
     4512         
     4513        return $post_connector; 
     4514 
     4515    } 
    44404516 
    44414517} // end class 
Note: See TracChangeset for help on using the changeset viewer.