Plugin Directory

Changeset 1405773


Ignore:
Timestamp:
04/27/2016 04:24:05 PM (10 years ago)
Author:
strider72
Message:
  • Split out get_styles() as function. A bit less spaghetti code for the Admin page.
  • Clean and clarify some comments and FIXMEs
File:
1 edited

Legend:

Unmodified
Added
Removed
  • graceful-pull-quotes/trunk/graceful-pull-quotes.php

    r1135814 r1405773  
    1919        - replace $style_path and $style_url with user options
    2020    TODO:   add optional "Uninstall" routine to deactivation hook
    21     TODO:   find better way to combine style and "core" CSS files into single call
     21    TODO:   find better way to combine style and "core" CSS files into single HTTP call
    2222    TODO:   (??) Allow for semi-random styling
    2323    TODO:   Option: [B]racket-capitalize quotes starting with lowercase letter
     
    199199// ========================
    200200
     201// FIXME: Bug -- If only one style present in Styles folder, it uses backup Default copy regardless of existing style.  Style not set in Settings when saved. Should be: If only one style in Styles folder, use it.
    201202// Fetch the stylesheet URL used for the active pullquote style
    202203    function get_pqcss( $theStyle = null ) {
     
    298299    }
    299300
     301    /**
     302     *
     303     * @return array
     304     */
     305    public function get_styles() {
     306        $arrStyles = array();
     307        if ( file_exists( $this->style_dir ) && $handle = opendir( $this->style_dir ) ) {
     308            while ( false !== ( $file = readdir( $handle ) ) ) {
     309                if ( substr( $file, 0, 1 ) != '.' ) {
     310                    $filename = basename( $file, '.css' );
     311                    if ( is_dir( trailingslashit( $this->style_dir ) . $file ) ) {
     312                        $file .= '/pullquote.css';
     313                    }
     314                    $arrStyles[ ] = array( 'name' => $filename, 'file' => $file );
     315                }
     316            }
     317            closedir( $handle );
     318
     319        }
     320        asort( $arrStyles);
     321        return $arrStyles;
     322    }
     323
     324
    300325// finally, the Settings Page itself
    301326    function settings_page() { 
     
    314339        // get options for use in form-setting functions
    315340        $opts = $this->get_options();
    316 
    317341        // Get array of CSS files for Style dropdown
    318         if ( file_exists( $this->style_dir ) && $handle = opendir( $this->style_dir ) ) {
    319             $arrStyles = array();
    320             while ( false !== ( $file = readdir( $handle ) ) ) {
    321                 if ( substr( $file, 0, 1) != '.' ) {
    322                     $filename = basename( $file, '.css' );
    323                     if( is_dir( trailingslashit( $this->style_dir ) . $file ) )
    324                         $file .= '/pullquote.css';
    325                     $arrStyles[] = array( 'name' => $filename, 'file'=> $file );
    326                 }
    327             }
    328             closedir( $handle );
    329             unset( $handle, $file, $filename, $fileurl );
    330         }
     342        $arrStyles = $this->get_styles();
     343
    331344        if ( ! isset( $arrStyles[0] ) ) {
    332345        // If no styles, use the core Default style
     
    428441    }
    429442
     443
    430444    // DEPRECATED -- maybe safe to remove
    431445
Note: See TracChangeset for help on using the changeset viewer.