Plugin Directory

Changeset 2637082


Ignore:
Timestamp:
11/29/2021 09:36:19 PM (3 years ago)
Author:
lukasznowicki
Message:

Options fixed, text formatting fixed

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  
    11<?php
    22/**
    3  * Minimal requirements for this version: PHP 7.0
     3 * Minimal requirements for this version: PHP 7.1
    44 *
    5  * @version   0.4.1
     5 * @version   0.5.1
    66 * @author    Łukasz Nowicki <[email protected]>
    77 * @copyright Łukasz Nowicki
     
    1313
    1414use Exception;
     15
    1516use const DIRECTORY_SEPARATOR;
    1617
     
    1819 * Class Autoloader
    1920 *
    20  * Use this class to handle auto loading classes, traits, implementations and abstracts.
     21 * Use this class to handle auto-loading classes, traits, implementations and abstracts.
    2122 * You may declare namespace and proper directory in the constructor (usually use this
    2223 * feature when you got only one) or by using registerHandler and addNamespace methods.
     
    3940     * the stack, so both will be sanitized as in addNamespace() method.
    4041     *
    41      * @param string $namespace Namespace you want to set
    42      * @param string $directory Directory you want to set
    43      * @param bool $exitOnFail Set this to false, if you have any fallback for class loader
     42     * @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
    4445     *
    4546     * @see Autoloader::registerHandler()
     
    4748     * @see Autoloader::$namespaces
    4849     */
    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 ) ) {
    5152            $this->registerHandler( $exitOnFail );
    5253            $this->addNamespace( $namespace, $directory );
     
    5556
    5657    /**
    57      * This method will register the class auto loading handler (using PHP
     58     * This method will register the class auto-loading handler (using PHP
    5859     * spl_autoload_register function). You may choose, whether you want
    5960     * your application to exit on fail (default) or not.
    6061     *
    61      * @param bool $exitOnFail Set this to false, if you have any fallback for class loader
     62     * @param  bool  $exitOnFail Set this to false, if you have any fallback for class loader
    6263     *
    6364     * @return bool
     
    8384
    8485    /**
    85      * Use this method to add namespace to the stack. Before addition, both namespace
     86     * Use this method to add namespace to the stack. Before the addition, both namespace
    8687     * and directory will be sanitized to be a valid namespace and directory. Valid,
    8788     * does not mean - existing one. It only means proper formatting using \ for
     
    8990     * separator for current operating system, using PHP constant DIRECTORY_SEPARATOR.
    9091     *
    91      * @param string $namespace Namespace you want to set
    92      * @param string $directory Directory you want to set
    93      * @param bool $prepend If 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.
    9495     *
    9596     * @return bool
     
    119120     * the namespace as well. Anyway, you should not, because it's not pretty.
    120121     *
    121      * @param string $namespace
     122     * @param  string $namespace
    122123     *
    123124     * @return string
     
    133134     * character.
    134135     *
    135      * @param string $string String to find in and replace the character
    136      * @param string $inUse String to be a replacement
     136     * @param  string  $string String to find in and replace the character
     137     * @param  string  $inUse String to be a replacement
    137138     *
    138139     * @return string
     
    146147            '/',
    147148        ], $inUse, $string );
    148         $string = rtrim( $string, $inUse ) . $inUse;
    149 
    150         return $string;
     149
     150        return rtrim( $string, $inUse ) . $inUse;
    151151    }
    152152
    153153    /**
    154154     * This method will prepare directory to a proper format, using
    155      * proper character as a directory separator. Of course we can
     155     * proper character as a directory separator. Of course, we can
    156156     * use / because it works for both Linux and Windows. We do that
    157157     * because I want everything to looks pretty.
    158158     *
    159      * @param string $directory
     159     * @param  string $directory
    160160     *
    161161     * @return string
     
    172172     * find proper file (will be loaded) or fail.
    173173     *
    174      * @param string $class
    175      *
    176      * @return string
     174     * @param  string $class
     175     *
     176     * @return string|null
    177177     *
    178178     * @see Autoloader::$namespaces
     
    180180     * @see Autoloader::callFile()
    181181     */
    182     public function classLoader( string $class ): string {
     182    public function classLoader( string $class ): ?string {
    183183        $classPrefix = $class;
    184184        while ( false !== $position = strrpos( $classPrefix, '\\' ) ) {
     
    192192        }
    193193
    194         return '';
     194        return null;
    195195    }
    196196
    197197    /**
    198198     * This method will check a combination of directories for called
    199      * class using callFile. If it find a proper combination, then
     199     * class using callFile. If it finds a proper combination, then
    200200     * a class file will be loaded.
    201201     *
    202      * @param string $namespace
    203      * @param string $relClass
    204      *
    205      * @return string
     202     * @param  string $namespace
     203     * @param  string $relClass
     204     *
     205     * @return string|null
    206206     *
    207207     * @see Autoloader::$namespaces
    208208     * @see Autoloader::callFile()
    209209     */
    210     protected function checkMappedFile( string $namespace, string $relClass ): string {
     210    protected function checkMappedFile( string $namespace, string $relClass ): ?string {
    211211        if ( false === isset( $this->namespaces[ $namespace ] ) ) {
    212             return '';
     212            return null;
    213213        }
    214214        foreach ( $this->namespaces[ $namespace ] as $baseDir ) {
     
    219219        }
    220220
    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,
    226226     * and it is not a directory, which is obvious.
    227227     *
    228      * @param string $filePath
     228     * @param  string $filePath
    229229     *
    230230     * @return bool
    231      * @noinspection PhpIncludeInspection
    232231     */
    233232    protected function callFile( string $filePath ): bool {
  • postpage-specific-custom-css/trunk/post-page-specific-custom-css.php

    r2528049 r2637082  
    33 * Plugin Name: Post/Page specific custom CSS
    44 * 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
    148 */
    159
     
    2418const PLUGIN_DIR  = __DIR__;
    2519
     20if ( ! 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/*
    2631const MENU_SLUG              = 'post-page-custom-css';
    2732const PARENT_MENU_SLUG       = 'options-general.php';
     
    3439    require_once __DIR__ . '/Phylax/Autoloader.php';
    3540}
    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*/
    4142
    4243new Plugin();
  • postpage-specific-custom-css/trunk/readme.txt

    r2528049 r2637082  
    33Tags: CSS, custom, post, page, specific, custom CSS, specific page, specific post, certain page, certain post, view, single
    44Requires at least: 5.0
    5 Tested up to: 5.7
     5Tested up to: 5.8
    66Contributors: lukasznowicki
    77Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LEXEGNRGEF7H4
    8 Stable tag: 0.2.2
     8Stable tag: 0.2.3
    99
    1010Post/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.
     
    4646
    4747== 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
    4858
    4959= 0.2.1 =
Note: See TracChangeset for help on using the changeset viewer.