Plugin Directory

Changeset 3233089


Ignore:
Timestamp:
02/01/2025 12:59:07 PM (11 months ago)
Author:
lumiblog
Message:

Version 3.0.6

Fix: PHP 8.2 Compatibility issue fixed

Location:
footnotes-made-easy
Files:
12 added
2 edited

Legend:

Unmodified
Added
Removed
  • footnotes-made-easy/trunk/footnotes-made-easy.php

    r3180184 r3233089  
    44Plugin URI: https://github.com/divibanks/footnotes-made-easy/
    55Description: Allows post authors to easily add and manage footnotes in posts.
    6 Version: 3.0.5
     6Version: 3.0.6
    77Author: Patrick Lumumba
    88Author URI: https://lumumbas.blog
     
    2020
    2121// Exit if accessed directly
    22 
    2322if ( ! defined( 'ABSPATH' ) ) {
    2423    exit;
     
    3433
    3534// Instantiate the class
    36 
    3735$swas_wp_footnotes = new swas_wp_footnotes();
    3836
    3937// Encapsulate in a class
    40 
    4138class swas_wp_footnotes {
    4239
    43     private $current_options;
    44     private $default_options;
    45 
    46     const OPTIONS_VERSION = "5"; // Incremented when the options array changes
    47 
    48     // Constructor
    49 
    50      function __construct() {
    51 
    52         // Define the implemented option styles
    53 
    54         $this -> styles = array(
    55                                 'decimal' => '1,2...10',
    56                                 'decimal-leading-zero' => '01, 02...10',
    57                                 'lower-alpha' => 'a,b...j',
    58                                 'upper-alpha' => 'A,B...J',
    59                                 'lower-roman' => 'i,ii...x',
    60                                 'upper-roman' => 'I,II...X',
    61                                 'symbol' => 'Symbol'
    62                                 );
    63 
    64         // Define default options
    65 
    66         $this->default_options = array('superscript' => true,
    67                                       'pre_backlink' => ' [',
    68                                       'backlink' => '↩',
    69                                       'post_backlink' => ']',
    70                                       'pre_identifier' => '',
    71                                       'inner_pre_identifier' => '',
    72                                       'list_style_type' => 'decimal',
    73                                       'list_style_symbol' => '†',
    74                                       'inner_post_identifier' => '',
    75                                       'post_identifier' => '',
    76                                       'pre_footnotes' => '',
    77                                       'post_footnotes' => '',
    78                                       'no_display_home' => false,
    79                                       'no_display_preview' => false,
    80                                       'no_display_archive' => false,
    81                                       'no_display_date' => false,
    82                                       'no_display_category' => false,
    83                                       'no_display_search' => false,
    84                                       'no_display_feed' => false,
    85                                       'combine_identical_notes' => true,
    86                                       'priority' => 11,
    87                                       'footnotes_open' => ' ((',
    88                                       'footnotes_close' => '))',
    89                                       'pretty_tooltips' => false,
    90                                       'version' => self::OPTIONS_VERSION
    91                                       );
    92 
    93         // Get the current settings or setup some defaults if needed
    94      
    95         $this->current_options = get_option( 'swas_footnote_options' );
    96         if ( ! $this->current_options ) {       
    97 
    98             $this->current_options = $this->default_options;
    99             update_option( 'swas_footnote_options', $this->current_options );
    100         } else {
    101 
    102             // Set any unset options
    103 
    104             if ( !isset( $this->current_options[ 'version' ] ) || $this->current_options[ 'version' ] !== self::OPTIONS_VERSION) {
    105                 foreach ( $this->default_options as $key => $value ) {
    106                     if ( !isset( $this->current_options[ $key ] ) ) {
    107                         $this->current_options[ $key ] = $value;
    108                     }
    109                 }
    110                 $this->current_options[ 'version' ] = self::OPTIONS_VERSION;
    111                 update_option( 'swas_footnote_options', $this->current_options );
    112             }
    113         }
    114 
    115         $footnotes_options = array();
    116            
    117         $post_array = $_POST;
    118 
    119         if ( !empty( $post_array[ 'save_options' ] ) && !empty( $post_array[ 'save_footnotes_made_easy_options' ] ) ) {
    120 
    121             $footnotes_options[ 'superscript' ] = ( array_key_exists( 'superscript', $post_array ) ) ? true : false;
    122 
    123             $footnotes_options[ 'pre_backlink' ] = sanitize_text_field( $post_array[ 'pre_backlink' ] );
    124             $footnotes_options[ 'backlink' ] = sanitize_text_field( $post_array[ 'backlink' ] );
    125             $footnotes_options[ 'post_backlink' ] = sanitize_text_field( $post_array[ 'post_backlink' ] );
    126 
    127             $footnotes_options[ 'pre_identifier' ] = sanitize_text_field( $post_array[ 'pre_identifier' ] );
    128             $footnotes_options[ 'inner_pre_identifier' ] = sanitize_text_field( $post_array[ 'inner_pre_identifier' ] );
    129             $footnotes_options[ 'list_style_type' ] = sanitize_text_field( $post_array[ 'list_style_type' ] );
    130             $footnotes_options[ 'inner_post_identifier' ] = sanitize_text_field( $post_array[ 'inner_post_identifier' ] );
    131             $footnotes_options[ 'post_identifier' ] = sanitize_text_field( $post_array[ 'post_identifier' ] );
    132             $footnotes_options[ 'list_style_symbol' ] = sanitize_text_field( $post_array[ 'list_style_symbol' ] );
    133 
    134 
    135             $footnotes_options[ 'pre_footnotes' ] = $post_array[ 'pre_footnotes' ];
    136             $footnotes_options[ 'post_footnotes' ] = $post_array[ 'post_footnotes' ];
    137 
    138             $footnotes_options[ 'no_display_home' ] = ( array_key_exists( 'no_display_home', $post_array ) ) ? true : false;
    139             $footnotes_options[ 'no_display_preview' ] = ( array_key_exists( 'no_display_preview', $post_array) ) ? true : false;
    140             $footnotes_options[ 'no_display_archive' ] = ( array_key_exists( 'no_display_archive', $post_array ) ) ? true : false;
    141             $footnotes_options[ 'no_display_date' ] = ( array_key_exists( 'no_display_date', $post_array ) ) ? true : false;
    142             $footnotes_options[ 'no_display_category' ] = ( array_key_exists( 'no_display_category', $post_array ) ) ? true : false;
    143             $footnotes_options[ 'no_display_search' ] = ( array_key_exists( 'no_display_search', $post_array ) ) ? true : false;
    144             $footnotes_options[ 'no_display_feed' ] = ( array_key_exists( 'no_display_feed', $post_array ) ) ? true : false;
    145 
    146             $footnotes_options[ 'combine_identical_notes' ] = ( array_key_exists( 'combine_identical_notes', $post_array ) ) ? true : false;
    147             $footnotes_options[ 'priority' ] = sanitize_text_field( $post_array[ 'priority' ] );
    148 
    149             $footnotes_options[ 'footnotes_open' ] = sanitize_text_field( $post_array[ 'footnotes_open' ] );
    150             $footnotes_options[ 'footnotes_close' ] = sanitize_text_field( $post_array[ 'footnotes_close' ] );
    151 
    152             $footnotes_options[ 'pretty_tooltips' ] = ( array_key_exists( 'pretty_tooltips', $post_array ) ) ? true : false;
    153 
    154             update_option( 'swas_footnote_options', $footnotes_options );
    155             $this->current_options = $footnotes_options;
    156 
    157         }
    158 
    159         // Hook me up
    160 
    161         add_action( 'the_content', array( $this, 'process' ), $this->current_options[ 'priority' ] );
    162         add_action( 'admin_menu', array( $this, 'add_options_page' ) );         // Insert the Admin panel.
    163         add_action( 'wp_head', array( $this, 'insert_styles' ) );
    164         if ( $this->current_options[ 'pretty_tooltips' ] ) add_action( 'wp_enqueue_scripts', array( $this, 'tooltip_scripts' ) );
    165 
    166         add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 10, 2 );
    167         add_filter( 'plugin_row_meta', array( $this, 'plugin_meta' ), 10, 2 ); 
    168     }
    169 
     40    // Declare the $styles property
     41    private $styles;
     42
     43    private $current_options;
     44    private $default_options;
     45
     46    const OPTIONS_VERSION = "5"; // Incremented when the options array changes
     47
     48    // Constructor
     49    function __construct() {
     50
     51        // Define the implemented option styles
     52        $this->styles = array(
     53            'decimal' => '1,2...10',
     54            'decimal-leading-zero' => '01, 02...10',
     55            'lower-alpha' => 'a,b...j',
     56            'upper-alpha' => 'A,B...J',
     57            'lower-roman' => 'i,ii...x',
     58            'upper-roman' => 'I,II...X',
     59            'symbol' => 'Symbol'
     60        );
     61
     62        // Define default options
     63        $this->default_options = array(
     64            'superscript' => true,
     65            'pre_backlink' => ' [',
     66            'backlink' => '↩',
     67            'post_backlink' => ']',
     68            'pre_identifier' => '',
     69            'inner_pre_identifier' => '',
     70            'list_style_type' => 'decimal',
     71            'list_style_symbol' => '†',
     72            'inner_post_identifier' => '',
     73            'post_identifier' => '',
     74            'pre_footnotes' => '',
     75            'post_footnotes' => '',
     76            'no_display_home' => false,
     77            'no_display_preview' => false,
     78            'no_display_archive' => false,
     79            'no_display_date' => false,
     80            'no_display_category' => false,
     81            'no_display_search' => false,
     82            'no_display_feed' => false,
     83            'combine_identical_notes' => true,
     84            'priority' => 11,
     85            'footnotes_open' => ' ((',
     86            'footnotes_close' => '))',
     87            'pretty_tooltips' => false,
     88            'version' => self::OPTIONS_VERSION
     89        );
     90
     91        // Get the current settings or setup some defaults if needed
     92        $this->current_options = get_option( 'swas_footnote_options' );
     93        if ( ! $this->current_options ) {       
     94            $this->current_options = $this->default_options;
     95            update_option( 'swas_footnote_options', $this->current_options );
     96        } else {
     97            // Set any unset options
     98            if ( !isset( $this->current_options[ 'version' ] ) || $this->current_options[ 'version' ] !== self::OPTIONS_VERSION) {
     99                foreach ( $this->default_options as $key => $value ) {
     100                    if ( !isset( $this->current_options[ $key ] ) ) {
     101                        $this->current_options[ $key ] = $value;
     102                    }
     103                }
     104                $this->current_options[ 'version' ] = self::OPTIONS_VERSION;
     105                update_option( 'swas_footnote_options', $this->current_options );
     106            }
     107        }
     108
     109        $footnotes_options = array();
     110        $post_array = $_POST;
     111
     112        if ( !empty( $post_array[ 'save_options' ] ) && !empty( $post_array[ 'save_footnotes_made_easy_options' ] ) ) {
     113            $footnotes_options[ 'superscript' ] = ( array_key_exists( 'superscript', $post_array ) ) ? true : false;
     114            $footnotes_options[ 'pre_backlink' ] = sanitize_text_field( $post_array[ 'pre_backlink' ] );
     115            $footnotes_options[ 'backlink' ] = sanitize_text_field( $post_array[ 'backlink' ] );
     116            $footnotes_options[ 'post_backlink' ] = sanitize_text_field( $post_array[ 'post_backlink' ] );
     117            $footnotes_options[ 'pre_identifier' ] = sanitize_text_field( $post_array[ 'pre_identifier' ] );
     118            $footnotes_options[ 'inner_pre_identifier' ] = sanitize_text_field( $post_array[ 'inner_pre_identifier' ] );
     119            $footnotes_options[ 'list_style_type' ] = sanitize_text_field( $post_array[ 'list_style_type' ] );
     120            $footnotes_options[ 'inner_post_identifier' ] = sanitize_text_field( $post_array[ 'inner_post_identifier' ] );
     121            $footnotes_options[ 'post_identifier' ] = sanitize_text_field( $post_array[ 'post_identifier' ] );
     122            $footnotes_options[ 'list_style_symbol' ] = sanitize_text_field( $post_array[ 'list_style_symbol' ] );
     123            $footnotes_options[ 'pre_footnotes' ] = $post_array[ 'pre_footnotes' ];
     124            $footnotes_options[ 'post_footnotes' ] = $post_array[ 'post_footnotes' ];
     125            $footnotes_options[ 'no_display_home' ] = ( array_key_exists( 'no_display_home', $post_array ) ) ? true : false;
     126            $footnotes_options[ 'no_display_preview' ] = ( array_key_exists( 'no_display_preview', $post_array) ) ? true : false;
     127            $footnotes_options[ 'no_display_archive' ] = ( array_key_exists( 'no_display_archive', $post_array ) ) ? true : false;
     128            $footnotes_options[ 'no_display_date' ] = ( array_key_exists( 'no_display_date', $post_array ) ) ? true : false;
     129            $footnotes_options[ 'no_display_category' ] = ( array_key_exists( 'no_display_category', $post_array ) ) ? true : false;
     130            $footnotes_options[ 'no_display_search' ] = ( array_key_exists( 'no_display_search', $post_array ) ) ? true : false;
     131            $footnotes_options[ 'no_display_feed' ] = ( array_key_exists( 'no_display_feed', $post_array ) ) ? true : false;
     132            $footnotes_options[ 'combine_identical_notes' ] = ( array_key_exists( 'combine_identical_notes', $post_array ) ) ? true : false;
     133            $footnotes_options[ 'priority' ] = sanitize_text_field( $post_array[ 'priority' ] );
     134            $footnotes_options[ 'footnotes_open' ] = sanitize_text_field( $post_array[ 'footnotes_open' ] );
     135            $footnotes_options[ 'footnotes_close' ] = sanitize_text_field( $post_array[ 'footnotes_close' ] );
     136            $footnotes_options[ 'pretty_tooltips' ] = ( array_key_exists( 'pretty_tooltips', $post_array ) ) ? true : false;
     137
     138            update_option( 'swas_footnote_options', $footnotes_options );
     139            $this->current_options = $footnotes_options;
     140        }
     141
     142        // Hook me up
     143        add_action( 'the_content', array( $this, 'process' ), $this->current_options[ 'priority' ] );
     144        add_action( 'admin_menu', array( $this, 'add_options_page' ) );         // Insert the Admin panel.
     145        add_action( 'wp_head', array( $this, 'insert_styles' ) );
     146        if ( $this->current_options[ 'pretty_tooltips' ] ) add_action( 'wp_enqueue_scripts', array( $this, 'tooltip_scripts' ) );
     147
     148        add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 10, 2 );
     149        add_filter( 'plugin_row_meta', array( $this, 'plugin_meta' ), 10, 2 ); 
     150    }
     151   
    170152    /**
    171153    * Searches the text and extracts footnotes
  • footnotes-made-easy/trunk/readme.txt

    r3180184 r3233089  
    66Tested up to: 6.7
    77Requires PHP: 7.4
    8 Stable tag: 3.0.5
     8Stable tag: 3.0.6
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3131
    3232== Getting Started ==
     33
     34[youtube https://www.youtube.com/watch?v=LuXMb8Hz4tc]
    3335
    3436Creating a footnote is incredibly simple - you just need to include your footnote in double parentheses, such as this...
     
    111113I use semantic versioning, with the first release being 1.0.
    112114
    113 = 3.0.5 [November 2, 2024] =
    114 * Maintenance: WordPress 6.7 Compatibility test passed.
    115 * Maintenance: PHP 8.2 Compatibility test passed.
    116 * Links on the options page updated.
     115= 3.0.6 [February 2, 2025] =
     116* Fix: PHP 8.2 Compatibility issue.
    117117
    118118
    119119== Upgrade Notice ==
    120120
    121 = 3.0.5 =
    122 * Maintenance: WordPress 6.7 Compatibility test passed.
    123 * Maintenance: PHP 8.2 Compatibility test passed.
    124 * Links on the options page updated.
     121= 3.0.6 =
     122* Fix: PHP 8.2 Compatibility issue.
Note: See TracChangeset for help on using the changeset viewer.