Plugin Directory

Changeset 1455865


Ignore:
Timestamp:
07/17/2016 12:35:24 AM (10 years ago)
Author:
graphems
Message:

Version 0.2: Feature added to select draft post. Tweak: added the post status column

Location:
list-urls/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • list-urls/trunk/readme.txt

    r1445920 r1455865  
    4141== Changelog ==
    4242
     43= 0.2 =
     44* Feature: Ability to choose or not if draft or unpublished post should be included
     45* Tweak: Added the post status column
     46
    4347= 0.1.1 =
    4448* Fix autoloader issue that was crashing the plugin on activation
  • list-urls/trunk/src/ListUrls/ListUrls.php

    r1445881 r1455865  
    3131        }
    3232
    33         $this->toCsv();
     33        $this->toCsv($_POST);
    3434        exit;
    3535
     
    4242     * @return bool
    4343     */
    44     protected function toCsv()
     44    protected function toCsv($request)
    4545    {
    4646        $types = $this->getPostTypes();
     
    5252        $csv = Writer::createFromFileObject(new SplTempFileObject());
    5353       
    54         $firstRow = ['Page Title','URL','Wordpress Id','Post Type'];
     54        $firstRow = ['Page Title','URL','Wordpress Id','Post Type', 'Post Status'];
    5555
    5656        $csv->insertOne($firstRow);
     
    6363              'posts_per_page' => -1
    6464            );
     65
     66            if(!isset($request['include_draft']))
     67            {
     68                $args['post_status'] = array('publish', 'future', 'private');
     69            }
     70
    6571            $query = new WP_Query( $args );
    6672            if ( $query->have_posts() ) {
     
    7884                    $url = get_the_permalink($post->ID);
    7985                    $id = $post->ID;
    80                     $rows[] = [$title,$url,$id,$type->labels->name];
     86                    $status = get_post_status($post->ID);
     87                    $rows[] = [$title,$url,$id,$type->labels->name, $status];
    8188
    8289                }
     
    109116        $csv->insertAll($rows);
    110117
    111         $csv->output('export.csv');
     118        $csv->output($this->getFileName());
    112119
    113120        return true;
     
    115122
    116123    /**
    117      *
     124     * Get all the post types available
    118125     *
    119126     * @param 
     
    131138
    132139    /**
    133      *
     140     * Get all the taxonimies available
    134141     *
    135142     * @param 
     
    145152    }
    146153
     154    /**
     155     *
     156     *
     157     * @param 
     158     * @return
     159     */
     160    protected function getFileName()
     161    {
     162        $siteName = get_bloginfo('name');
     163
     164        if(empty($siteName))
     165        {
     166            return 'urlslist.csv';
     167        }       
     168
     169        $siteName = preg_replace('/[^A-Za-z0-9\-\']/', '', $siteName);
     170
     171        $siteName = str_replace(" ","-", $siteName);
     172
     173        return $siteName.'-urlslist.csv';
     174
     175    }
     176
    147177}
  • list-urls/trunk/views/list-urls.php

    r1445881 r1455865  
    33<p>Click the button below to download a csv file or all the URLs on your site. Please note if your site is very large it might take a while to generate the CSV.</p>
    44    <div>
     5        <fieldset><legend class="screen-reader-text"><span>Options</span></legend><label for="include_draft">
     6        <input name="include_draft" type="checkbox" id="include_draft" value="1">
     7        Include draft and unpublished?</label>
     8        </fieldset>
    59        <p>
    610            <input class="button" id="getUrls" name="wp_list_urls_download" type="submit" value="Download CSV">
  • list-urls/trunk/wp-listurls.php

    r1445920 r1455865  
    44Plugin URI: http://www.graphem.ca
    55Description: Get a list of all the current urls of your Wordpress site
    6 Version: 0.1.1
     6Version: 0.2
    77Author: Graphem Solutions Inc.
    88Author URI: http://www.graphem.ca
Note: See TracChangeset for help on using the changeset viewer.