Changeset 2637082
- Timestamp:
- 11/29/2021 09:36:19 PM (3 years ago)
- Location:
- postpage-specific-custom-css
- Files:
-
- 15 added
- 3 edited
- 1 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
postpage-specific-custom-css/trunk/Phylax/Autoloader.php
r2528049 r2637082 1 1 <?php 2 2 /** 3 * Minimal requirements for this version: PHP 7. 03 * Minimal requirements for this version: PHP 7.1 4 4 * 5 * @version 0. 4.15 * @version 0.5.1 6 6 * @author Łukasz Nowicki <[email protected]> 7 7 * @copyright Łukasz Nowicki … … 13 13 14 14 use Exception; 15 15 16 use const DIRECTORY_SEPARATOR; 16 17 … … 18 19 * Class Autoloader 19 20 * 20 * Use this class to handle auto 21 * Use this class to handle auto-loading classes, traits, implementations and abstracts. 21 22 * You may declare namespace and proper directory in the constructor (usually use this 22 23 * feature when you got only one) or by using registerHandler and addNamespace methods. … … 39 40 * the stack, so both will be sanitized as in addNamespace() method. 40 41 * 41 * @param string $namespaceNamespace you want to set42 * @param string $directoryDirectory you want to set43 * @param bool $exitOnFailSet this to false, if you have any fallback for class loader42 * @param string|null $namespace Namespace you want to set 43 * @param string|null $directory Directory you want to set 44 * @param bool $exitOnFail Set this to false, if you have any fallback for class loader 44 45 * 45 46 * @see Autoloader::registerHandler() … … 47 48 * @see Autoloader::$namespaces 48 49 */ 49 public function __construct( string $namespace = '', string $directory = '', bool $exitOnFail = true ) {50 if ( ( '' !== $namespace ) && ( '' !==$directory ) ) {50 public function __construct( ?string $namespace = null, ?string $directory = null, bool $exitOnFail = true ) { 51 if ( ! is_null( $namespace ) && ! is_null( $directory ) ) { 51 52 $this->registerHandler( $exitOnFail ); 52 53 $this->addNamespace( $namespace, $directory ); … … 55 56 56 57 /** 57 * This method will register the class auto 58 * This method will register the class auto-loading handler (using PHP 58 59 * spl_autoload_register function). You may choose, whether you want 59 60 * your application to exit on fail (default) or not. 60 61 * 61 * @param bool $exitOnFailSet this to false, if you have any fallback for class loader62 * @param bool $exitOnFail Set this to false, if you have any fallback for class loader 62 63 * 63 64 * @return bool … … 83 84 84 85 /** 85 * Use this method to add namespace to the stack. Before addition, both namespace86 * Use this method to add namespace to the stack. Before the addition, both namespace 86 87 * and directory will be sanitized to be a valid namespace and directory. Valid, 87 88 * does not mean - existing one. It only means proper formatting using \ for … … 89 90 * separator for current operating system, using PHP constant DIRECTORY_SEPARATOR. 90 91 * 91 * @param string $namespaceNamespace you want to set92 * @param string $directoryDirectory you want to set93 * @param bool $prependIf you want to add the namespace/directory pair in front of the stack, just set it to true.92 * @param string $namespace Namespace you want to set 93 * @param string $directory Directory you want to set 94 * @param bool $prepend If you want to add the namespace/directory pair in front of the stack, just set it to true. 94 95 * 95 96 * @return bool … … 119 120 * the namespace as well. Anyway, you should not, because it's not pretty. 120 121 * 121 * @param string$namespace122 * @param string $namespace 122 123 * 123 124 * @return string … … 133 134 * character. 134 135 * 135 * @param string $stringString to find in and replace the character136 * @param string $inUseString to be a replacement136 * @param string $string String to find in and replace the character 137 * @param string $inUse String to be a replacement 137 138 * 138 139 * @return string … … 146 147 '/', 147 148 ], $inUse, $string ); 148 $string = rtrim( $string, $inUse ) . $inUse; 149 150 return $string; 149 150 return rtrim( $string, $inUse ) . $inUse; 151 151 } 152 152 153 153 /** 154 154 * This method will prepare directory to a proper format, using 155 * proper character as a directory separator. Of course we can155 * proper character as a directory separator. Of course, we can 156 156 * use / because it works for both Linux and Windows. We do that 157 157 * because I want everything to looks pretty. 158 158 * 159 * @param string$directory159 * @param string $directory 160 160 * 161 161 * @return string … … 172 172 * find proper file (will be loaded) or fail. 173 173 * 174 * @param string$class175 * 176 * @return string 174 * @param string $class 175 * 176 * @return string|null 177 177 * 178 178 * @see Autoloader::$namespaces … … 180 180 * @see Autoloader::callFile() 181 181 */ 182 public function classLoader( string $class ): string {182 public function classLoader( string $class ): ?string { 183 183 $classPrefix = $class; 184 184 while ( false !== $position = strrpos( $classPrefix, '\\' ) ) { … … 192 192 } 193 193 194 return '';194 return null; 195 195 } 196 196 197 197 /** 198 198 * This method will check a combination of directories for called 199 * class using callFile. If it find a proper combination, then199 * class using callFile. If it finds a proper combination, then 200 200 * a class file will be loaded. 201 201 * 202 * @param string$namespace203 * @param string$relClass204 * 205 * @return string 202 * @param string $namespace 203 * @param string $relClass 204 * 205 * @return string|null 206 206 * 207 207 * @see Autoloader::$namespaces 208 208 * @see Autoloader::callFile() 209 209 */ 210 protected function checkMappedFile( string $namespace, string $relClass ): string {210 protected function checkMappedFile( string $namespace, string $relClass ): ?string { 211 211 if ( false === isset( $this->namespaces[ $namespace ] ) ) { 212 return '';212 return null; 213 213 } 214 214 foreach ( $this->namespaces[ $namespace ] as $baseDir ) { … … 219 219 } 220 220 221 return '';222 } 223 224 /** 225 * This method will load the class file, if it is readable 221 return null; 222 } 223 224 /** 225 * This method will load the class file, if it is readable, 226 226 * and it is not a directory, which is obvious. 227 227 * 228 * @param string$filePath228 * @param string $filePath 229 229 * 230 230 * @return bool 231 * @noinspection PhpIncludeInspection232 231 */ 233 232 protected function callFile( string $filePath ): bool { -
postpage-specific-custom-css/trunk/post-page-specific-custom-css.php
r2528049 r2637082 3 3 * Plugin Name: Post/Page specific custom CSS 4 4 * Plugin URI: https://wordpress.org/plugins/postpage-specific-custom-css/ 5 * Description: Post/Page specific custom CSS will allow you to add cascade stylesheet to specific posts/pages. It will give you special area in the post/page edit field to attach your CSS. It will also let you decide if this CSS has to be added in multi-page/post view (like archive posts) or only in a single view. 6 * Version: 0.3.0 7 * Author: Łukasz Nowicki 8 * Author URI: https://lukasznowicki.info/ 9 * Requires at least: 5.0 10 * Requires PHP: 7.0 11 * Tested up to: 5.7 12 * Text Domain: postpage-specific-custom-css 13 * Domain Path: /languages 5 * Description: Post/Page specific custom CSS will allow you to add cascade stylesheet to specific posts/pages. It will give you special area in the post/page edit field to attach your CSS. It will also let you decide if this CSS has to be 6 * added in multi-page/post view (like archive posts) or only in a single view. Version: 0.3.0 Author: Łukasz Nowicki Author URI: https://lukasznowicki.info/ Requires at least: 5.0 Requires PHP: 7.1 Tested up to: 5.8 Text Domain: 7 * postpage-specific-custom-css Domain Path: /languages 14 8 */ 15 9 … … 24 18 const PLUGIN_DIR = __DIR__; 25 19 20 if ( ! class_exists( 'Phylax\Autoloader' ) ) { 21 require_once PLUGIN_DIR . '/Phylax/Autoloader.php'; 22 } 23 24 $ppsccAutoloader = new Autoloader(); 25 $ppsccAutoloader->registerHandler(); 26 $ppsccAutoloader->addNamespace( 'Phylax\WPPlugin\PPCustomCSS', PLUGIN_DIR . '/Phylax/WPPlugin/PPCustomCSS' ); 27 28 29 30 /* 26 31 const MENU_SLUG = 'post-page-custom-css'; 27 32 const PARENT_MENU_SLUG = 'options-general.php'; … … 34 39 require_once __DIR__ . '/Phylax/Autoloader.php'; 35 40 } 36 37 $autoloader = new Autoloader(); 38 $autoloader->registerHandler(); 39 $autoloader->addNamespace( 'Phylax\WPPlugin\PPCustomCSS', __DIR__ . '/Phylax/WPPlugin/PPCustomCSS' ); 40 $autoloader->addNamespace( 'Phylax\WordPress', __DIR__ . '/Phylax/WordPress' ); 41 */ 41 42 42 43 new Plugin(); -
postpage-specific-custom-css/trunk/readme.txt
r2528049 r2637082 3 3 Tags: CSS, custom, post, page, specific, custom CSS, specific page, specific post, certain page, certain post, view, single 4 4 Requires at least: 5.0 5 Tested up to: 5. 75 Tested up to: 5.8 6 6 Contributors: lukasznowicki 7 7 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LEXEGNRGEF7H4 8 Stable tag: 0.2. 28 Stable tag: 0.2.3 9 9 10 10 Post/Page specific custom CSS will allow you to add cascade stylesheet to specific posts/pages. It will give you special area in the post/page edit field to attach your CSS. It will also let you decide if this CSS has to be added in multi-page/post view (like archive posts) or only in a single view. … … 46 46 47 47 == Changelog == 48 49 = 0.2.3 = 50 * Release date: 2021-11-29 51 * Fixed options saving 52 * Fixed text formatting 53 54 = 0.2.2 = 55 * Release date: 2021-05-02 56 * Remove notes for 57 * Fixed text formatting 48 58 49 59 = 0.2.1 =
Note: See TracChangeset
for help on using the changeset viewer.