Plugin Directory

Changeset 1950458


Ignore:
Timestamp:
10/02/2018 07:54:28 PM (7 years ago)
Author:
paulswarthout
Message:

Fixed a bug in a new child theme's functions.php file where the path to the child's stylesheet was incorrect.

Location:
child-themes-helper
Files:
52 added
3 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • child-themes-helper/trunk/classes/class_ajax_functions.php

    r1947069 r1950458  
    77if ( ! class_exists( 'pas_cth_AJAXFunctions' ) ) {
    88    class pas_cth_AJAXFunctions {
     9        public $activeThemeInfo;
    910        private $pluginDirectory;
    1011        private $pluginName;
    1112        private $pluginFolder;
    12         public $activeThemeInfo;
    1313        private $colorPicker;
    1414        private $libraryFunctions;
     
    403403                            'themeURI'      => sanitize_text_field( $_POST['themeURI'] )
    404404                        ];
    405 
    406405            if ( 0 === strlen( trim( $inputs['childThemeName'] ) ) ) {
    407406                $this->libraryFunctions->displayError( "Notice",
     
    459458            $styleFile = fopen( $childThemePath . PAS_CTH_SEPARATOR . "style.css", "w" );
    460459            $newlineChar = "\n";
    461 /*
    462             $inputs =   [
    463                             'themeURI'      => sanitize_text_field( $_POST['themeURI'] ),
    464                             'description'   => sanitize_textarea_field( $_POST['description'] ),
    465                             'authorName'    => sanitize_text_field( $_POST['authorName'] ),
    466                             'authorURI'     => sanitize_text_field( $_POST['authorURI'] ),
    467                             'templateTheme' => sanitize_text_field( $_POST['templateTheme'] ),
    468                             'version'       => sanitize_text_field( $_POST['version'] )
    469                         ];
    470 */
     460
    471461            fwrite( $styleFile, "/*" . $newlineChar );
    472462            fwrite( $styleFile, " Theme Name: " . $childThemeName       . $newlineChar );
     
    482472            // Create the functions.php file for the child theme. Use the wp_enqueue_style( ) function
    483473            // to correctly set up the stylesheets for the child theme.
     474
     475            $stylesheetURL = dirname(get_stylesheet_uri());
     476            $stylesheetURL = $this->libraryFunctions->setDelimiters($stylesheetURL);
     477            $stylesheetURL = $this->libraryFunctions->dirUp($stylesheetURL, 1);
     478            $stylesheetURL .= PAS_CTH_SEPARATOR . $childThemeStylesheet . PAS_CTH_SEPARATOR . "style.css";
     479
    484480            $functionsFile = fopen( $childThemePath . PAS_CTH_SEPARATOR . "functions.php", "w" );
    485481            fwrite( $functionsFile, "<" . "?" . "PHP" . $newlineChar );
     
    492488                 " get_template_directory_uri( ) . " .
    493489                 " '/style.css' );" . $newlineChar );
    494             fwrite( $functionsFile, "\twp_enqueue_style( '" . $childThemeStylesheet . "-style', " .
    495                  "dirname( __FILE__ ) . '/style.css' );" . $newlineChar );
     490            fwrite( $functionsFile, "\twp_enqueue_style( '" .
     491                                    $childThemeStylesheet . "-style', " .
     492                                    "'$stylesheetURL' );" . $newlineChar );
    496493            fwrite( $functionsFile, "}" . $newlineChar );
    497494            fwrite( $functionsFile, "?>" );
  • child-themes-helper/trunk/classes/class_childThemesHelper.php

    r1947069 r1950458  
    406406                echo "<br><br>"; // replace with CSS in future release;
    407407                echo "<form>";
     408                echo "<input type='hidden' name='themeRoot' value='" . $this->activeThemeInfo->childThemeRoot . "'>";
    408409                echo "<input type='hidden' name='action' value='createChildTheme'>";
    409410                echo "<input type='hidden' name='href' value='" . admin_url( "themes.php" ) . "'>";
  • child-themes-helper/trunk/classes/class_common_functions.php

    r1947599 r1950458  
    347347        }
    348348
     349        public function setDelimiters($path, $delimiter = PAS_CTH_SEPARATOR) {
     350            $path = str_replace( "\\", "|+|", $path );
     351            $path = str_replace( "/", "|+|", $path );
     352            $path = str_replace( "|+|", $delimiter, $path );
     353            return $path;
     354        }
     355        public function dirUp($path, $levels = 1) {
     356            $delimiter = PAS_CTH_SEPARATOR;
     357            $folders = explode($delimiter, $path);
     358            for ($ndx = 0; $ndx < $levels; $ndx++) {
     359                unset($folders[count($folders) - 1] );
     360            }
     361            return implode($delimiter, $folders);
     362        }
     363
    349364    }
    350365}
  • child-themes-helper/trunk/pasChildThemes.php

    r1948824 r1950458  
    44    Plugin URI: http://www.paulswarthout.com/Child-Themes-Helper/
    55    Description: ( 1 ) Copies files from the template theme to the child theme, perfectly duplicating the path structure. ( 2 ) Removes file from the child theme, and removes any empty folders that were made empty by the removal of the child theme file. ( 3 ) Creates new child themes from installed template themes.
    6     Version: 1.1.2
     6    Version: 1.1.3
    77    Author: Paul A. Swarthout
    88    Author URI: http://www.PaulSwarthout.com
  • child-themes-helper/trunk/readme.txt

    r1948824 r1950458  
    66Requires at least: 4.7.0
    77Tested up to: 4.9.8
    8 Stable tag: 1.1.2
     8Stable tag: 1.1.3
    99Requires PHP: 5.5.38
    1010License: GPLv2 or later
     
    32321. **Notes**
    3333    - *Screenshot*
    34         The temporary graphic is referred to as the ScreenShot because the filename is "screenshot.png" and is located in the root folder of your theme. The name, nor the location is determined by the WordPress core.
     34        The temporary graphic is referred to as the ScreenShot because the filename is "screenshot.png" and is located in the root folder of your theme. The filename and the location are defined by the WordPress core and cannot be changed by this (or any) plugin.
    3535
    36         Your browser will attempt to cache the screenshot. If you modify the ScreenShot graphic and you do not see any changes when you generate a new one, you will need to clear your browser's image and file cache.
     36        Your browser will cache the screenshot file whenever possible. If you modify the ScreenShot graphic and you do not see any changes when you generate a new one, then you will need to clear your browser's image and file cache.
    3737       
    3838        If you generate a screenshot graphic and you only see the background (i.e., no words), just generate the screenshot again. This happens when the selected font does not exist in the assets/fonts folder of the Child Themes Helper plugin. If you are updating from version 1.0, you will see this happen the first time that you generate a screenshot since the original fonts were deleted and replaced by Google Fonts.
    3939
    40         Most developers will replace the screenshot file with the theme's header image. This feature is meant to provide a *temporary* graphic.
     40        Most developers will replace this generated screenshot file with a graphic of their own. This feature is meant to provide a *temporary* graphic that quickly and easily identifies the child theme name and its parent theme.
     41
     42        In a future release, there will be a lock feature on the options page to prevent accidental overwrites of the screenshot file. Also, in a future release, there will be the ability to select an existing graphic and crop it as necessary, instead of generating one.
    4143
    4244    - *Child Themes Helper access*
     
    4749   
    4850    - *Child Themes Helper plugin code*
    49         This plugin can be found on [GitHub](https://github.com/PaulSwarthout/pasChildThemes).
     51        The GitHub repository for this plugin can be found [here](https://github.com/PaulSwarthout/pasChildThemes).
     52
     53    - *Development versions*
     54        Versions 1\.1\.3 and 1\.0 are available for download and install.
    5055
    5156== Installation ==
     
    6065- Reminder: Only 1 theme can be active at a time. This plugin works with a child theme. Even though a child theme and a parent theme go together, only the child theme or the parent theme can be marked as active.
    6166
     67- *If you downloaded the Child Themes Helper plugin, directly, from the [WordPress Plugin Page](https://wordpress.org/plugins/child-themes-helper/)*, then follow these instructions to install.
     68    1. If you have already tried this plugin and you are trying a different version through this installation method, I highly recommend that you deactivate the plugin and delete it before following the next steps. There are multiple files that existed in earlier versions that do not exist or are no longer used in later versions. If you don't want to delete it, first, then at least deactivate it.
     69    1. Using your favorite FTP client, find the wp-content/plugins folder and create the child-themes-helper sub folder.
     70    1. Unzip the downloaded file and copy the contents to the wp-content/plugins/child-themes-helper folder on your web server. Overwrite anything that previously existed.
     71    1. Activate the Child Themes Helper plugin.
     72    1. You're ready to go. You should see the menu option "Child Themes Helper" on your dashboard menu just below the Appearance menu item.
     73
    6274== Frequently Asked Questions ==
     75
     76= Why do the prompts sometimes disappear without making any changes? =
     77
     78You have to click precisely on the button. If you click anywhere else in the prompt, besides the buttons (near, but not on the button, for example), the prompt will disappear without doing anything.
     79This was supposed to be a feature to prevent "stuck" prompts that couldn't be removed should an error occur.
     80However, all such errors were fixed prior to releasing this plugin as version 1.0.
     81This problem will be remedied in a future release and only the "dismiss" button in the lower right corner will cause the prompt to just vanish.
    6382
    6483= I generated a screenshot but it didn't change. Why not? =
     
    82101
    83102== Changelog ==
     103= 1.1.3 =
     104    When creating a child theme, the path to the child theme stylesheet was wrong in functions.php. I used dirname( __FILE__ ) . "/style.css", but this created a server rooted path not a URL path to the child theme's stylesheet. This is now fixed.
     105
     106    Updates to the readme.txt file.
     107
     108= 1.1.2 =
     109    Discovered a non-unique "global" variable. Variables outside classes are global by their very nature. They must be unique across all of WordPress and any plugins or themes written or not yet written. This plugin prefixes all objects with global scope with the prefix "pas_cth_". The $pluginDirectory variable in pasChildThemes.php needed to be renamed to $pas_cth_pluginDirectory.
     110   
    84111= 1.1.1 =
    85 **oops:** Version 1\.1 was missing some files. Caused it to crash. Files that were new to 1.1 didn't get added to the WordPress plugin repository.
     112    Version 1\.1 was missing some files. This caused the plugin to crash when activated.
     113    Files that were new to version 1.1 didn't get added to the WordPress plugin repository.
    86114
    87115= 1.1 =
     
    106134== Upgrade Notice ==
    107135
    108 No additional versions available yet.
     136= 1.1.3 =
     137- Fixed a bug: The path to the child theme's stylesheet in the functions.php was incorrect.
     138- If you only use the Child Themes Helper for its primary purpose of copying files from the parent theme to a child theme, then this change will not effect you and there is no reason to update at this time.
     139- However, if you plan on creating a new child theme with this plugin, then you should update this plugin first.
Note: See TracChangeset for help on using the changeset viewer.