🔒 EXCLUSIVE: Changeset/ - HD Photos!

Changeset 1050490


Ignore:
Timestamp:
12/20/2014 08:51:58 PM (11 years ago)
Author:
DaganLev
Message:

added template support on themes with templates

Location:
bulk-page-creator
Files:
6 added
3 edited

Legend:

Unmodified
Added
Removed
  • bulk-page-creator/trunk/bulk-page-creator.php

    r799716 r1050490  
    44Plugin URI: http://solid-code.co.uk/2011/05/bulk-page-creator/
    55Description: Allows you to create multiple pages in a batch/bulk manner saving time when initially setting up your WordPress site.
    6 Version: 1.0.7
     6Version: 1.0.8
    77Author: Dagan Lev
    88Author URI: http://solid-code.co.uk
     
    6161        if(isset($_POST['sc-pages'])&&$_POST['sc-pages']!=''){
    6262            //form submitted
    63             if(preg_match_all('/(\d+\|(-|new)?\d+\|[^\n]*)/',$_POST['sc-pages'],$match_pg)){
     63            if(preg_match_all('/(\d+\|(-|new)?\d+\|[^\|]*\|[^\n]*)/',$_POST['sc-pages'],$match_pg)){
    6464                $newpage = array();
    6565                foreach($match_pg[0] as $pg_res){
    66                     if(preg_match('/((\d+)\|((-|new)?\d+)\|(.*))/',$pg_res,$rres)){
     66                    if(preg_match('/((\d+)\|((-|new)?\d+)\|([^\|]*)\|(.*))/',$pg_res,$rres)){
    6767                        $parent = -1;
    6868                        if($rres[4]=='new'){
     
    8383                            'post_parent' => $parent,
    8484                            'post_title' => rtrim($rres[5]),
     85                            'page_template' => rtrim($rres[6]),
    8586                            'post_content' => $pcontent);
    8687                       
     
    8889                        $params['menu_order'] = $wpdb->get_var("SELECT MAX(menu_order)+1 AS menu_order FROM {$wpdb->posts} WHERE post_type='page'");
    8990                        $wpdb->flush();
    90                        
     91
    9192                        $newpage[$rres[2]] = wp_insert_post($params);
    9293                    }
     
    114115            <small>allows you to create multiple pages by seperating them with a comma; I.E. test1,test2,test3 - will create three pages (do not leave any spaces).</small>
    115116            </p>
     117            <?php $templates = get_page_templates(); ?>
    116118            <table>
    117119                <tr>
    118120                    <td>Page Name</td>
    119121                    <td>Parent</td>
     122                    <?php echo($templates ? '<td>Template</td>' : ''); ?>
    120123                    <td>&nbsp;</td>
    121124                </tr>
     
    125128                        <?php wp_dropdown_pages('sort_column=menu_order&post_status=draft,publish&show_option_none=(No Parent)'); ?>
    126129                    </td>
     130                    <?php
     131                        if($templates){
     132                            echo '<td>
     133                                <select id="page_template" name="page_template">
     134                                    <option value="">Default</option>';
     135                            foreach ( $templates as $template_name => $template_filename ) {
     136                                echo "<option value=\"$template_filename\">$template_name</option>";
     137                            }
     138                            echo '</select></td>';
     139                        }
     140                    ?>
    127141                    <td><input onclick="sc_add_page();" type="button" class="button-secondary" value="Add Page" /></td>
    128142                </tr>
  • bulk-page-creator/trunk/my-script.js

    r799716 r1050490  
    6969        }
    7070        var parent = jQuery('#page_id').val();
     71        var template = jQuery('#page_template').val();
     72        var template_text = jQuery('#page_template option[value="'+ template +'"]').text();
     73        if(!template) template = '';
     74        if(!template_text) template_text = '';
     75       
    7176        if(parent==''){
    7277            parent = -1;
    73             jQuery('ul.sc-pages').append('<li class="page-item-new' + pageid + '">' + jQuery('#sc-page-name').val() + ' <a href="JavaScript:sc_del_page(' + pageid + ');">Remove</a></li>');
     78            jQuery('ul.sc-pages').append('<li class="page-item-new' + pageid + '">' + jQuery('#sc-page-name').val() + (template!='' ? ' (' + template_text + ')' : '') + ' <a href="JavaScript:sc_del_page(' + pageid + ');">Remove</a></li>');
    7479            jQuery('#page_id').append('<option value="new' + pageid + '">' + jQuery('#sc-page-name').val() + '</option>');
    7580        }else{
     
    8287                }
    8388            }
    84             jQuery('li.page-item-' + parent).append('<li class="page-item-new' + pageid + '">' + jQuery('#sc-page-name').val() + ' <a href="JavaScript:sc_del_page(' + pageid + ');">Remove</a></li>');
     89            jQuery('li.page-item-' + parent).append('<li class="page-item-new' + pageid + '">' + jQuery('#sc-page-name').val() + (template!='' ? ' (' + template_text + ')' : '') + ' <a href="JavaScript:sc_del_page(' + pageid + ');">Remove</a></li>');
    8590            jQuery('#page_id option[value=' + parent + ']').after('<option class="p_' + parent + '" value="new' + pageid + '">' + parentspace + jQuery('#sc-page-name').val() + '</option>');
    8691        }
    87         jQuery('#sc-pages').val(jQuery('#sc-pages').val() + pageid + '|' + parent + '|' + jQuery('#sc-page-name').val() + '\n');
     92        jQuery('#sc-pages').val(jQuery('#sc-pages').val() + pageid + '|' + parent + '|' + jQuery('#sc-page-name').val() + '|' + template + '\n');
    8893               
    8994        //reset the form
  • bulk-page-creator/trunk/readme.txt

    r799716 r1050490  
    33Tags: Solid Code, Dagan Lev, Bulk Page Creator, batch action, add pages, add posts
    44Requires at least: 3.1
    5 Tested up to: 3.1
     5Tested up to: 4.1
    66Stable tag: trunk
    77
     
    4444Added script to add pages in the page section when accedently submitting form
    4545
     46= 1.0.8 =
     47Added template support - if templates exist in the theme will create a template dropdown to choose from when adding pages
     48
    4649== Screenshots ==
    4750
    48511. View of bulk page creator screen
     52
     53== Upgrade Notice ==
     54
     55Added template support - if templates exist in the theme will create a template dropdown to choose from when adding pages
Note: See TracChangeset for help on using the changeset viewer.