Plugin Directory

Changeset 3231152


Ignore:
Timestamp:
01/29/2025 09:29:59 AM (12 months ago)
Author:
wowholic
Message:

v1.1.0

Location:
wowholic-core/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • wowholic-core/trunk/assets/css/main.css

    r2645312 r3231152  
    22    cursor: pointer;
    33}
    4 
    5 .wowcore-install-plugins-wait {
    6     display: none;
    7     margin-top: 1rem;
    8 }
    9 
    10 .wowcore-install-plugins-wait .spinner {
    11     float: none;
    12     margin: 0;
    13     margin-right: 0.25rem;
    14 }
  • wowholic-core/trunk/assets/js/main.js

    r2645312 r3231152  
    11document.addEventListener('DOMContentLoaded', () => {
    2     const pluginsBtn = document.querySelector('#wowcore-install-recommended-plugins');
    3     const pleaseWaitBox = document.querySelector('.wowcore-install-plugins-wait');
    4     pluginsBtn.addEventListener('click', async (evt) => {
    5         evt.preventDefault();
    6 
    7         const recommendedPluginsEls = document.querySelectorAll('#recommended-plugins input[name="plugins"]:checked');
    8         const recommendedPlugins = [...recommendedPluginsEls].map(el => el.value);
    9 
    10         if (!recommendedPlugins.length) return;
    11 
    12         pluginsBtn.setAttribute('disabled', '');
    13         pleaseWaitBox.style.display = 'block';
    14 
    15         const data = {
    16             action: 'wowcore_install_recommended_plugins',
    17             plugins: recommendedPlugins,
    18         };
    19 
    20         const formData = new FormData();
    21         for (const key in data) {
    22             formData.append(key, data[key]);
    23         }
    24 
    25         const response = await fetch(ajaxurl, {
    26             method: 'POST',
    27             body: formData,
    28         }).then(res => res.json());
    29 
    30         if (response.success) {
    31             window.location.reload();
    32         } else {
    33             pluginsBtn.removeAttribute('disabled');
    34             pleaseWaitBox.style.display = 'hidden';
    35         }
    36     });
    372});
  • wowholic-core/trunk/includes/actions/acf.php

    r2645312 r3231152  
    3333    } );
    3434}
     35
     36/**
     37 * Add label next to Flexible Content Layout name
     38 */
     39if ( carbon_get_theme_option( 'wowcore_acf_flexible_contents' ) ) {
     40    $flexible_contents = carbon_get_theme_option( 'wowcore_acf_flexible_contents' ) ?? [];
     41
     42    if ( count( $flexible_contents ) > 0 ) {
     43        foreach ( $flexible_contents as $flexible_content ) {
     44            $flexible_content_name = $flexible_content['flexible_content_name'];
     45            $title_field_name      = $flexible_content['title_field_name'];
     46
     47            add_filter( 'acf/fields/flexible_content/layout_title/name=' . $flexible_content_name, function ( $title, $field, $layout, $i ) use ( $title_field_name ) {
     48                if ( $text = get_sub_field( $title_field_name ) ) {
     49                    $title .= ' - <b>' . esc_html( $text ) . '</b>';
     50                }
     51
     52                return $title;
     53            }, 10, 4 );
     54        }
     55    }
     56}
  • wowholic-core/trunk/includes/actions/general.php

    r2811120 r3231152  
    9797if ( carbon_get_theme_option( 'wowcore_encrypt_email_shortcode' ) ) {
    9898    add_shortcode( 'email', function ( $atts = [], $content = null ) {
    99         $atts = array_change_key_case( (array) $atts, CASE_LOWER );
    100         $array_atts = shortcode_atts(
    101             array(
    102                 'title' => '',
    103             ), $atts
    104         );
     99        $atts      = array_change_key_case( (array) $atts, CASE_LOWER );
     100        $array_atts = shortcode_atts(
     101            array(
     102                'title' => '',
     103            ), $atts
     104        );
    105105
    106106        if ( ! is_email( $content ) ) {
     
    108108        }
    109109
    110         if ( $array_atts['title'] ) {
    111             $title = esc_html__( $array_atts['title'], '' );
    112         }
    113         else {
    114             $title = '%s';
    115         }
     110        if ( $array_atts['title'] ) {
     111            $title = esc_html__( $array_atts['title'], '' );
     112        } else {
     113            $title = '%s';
     114        }
    116115
    117116        $content    = antispambot( $content );
    118117        $email_link = sprintf( 'mailto:%s', $content );
    119118
    120         return sprintf( '<a href="%s">'  . $title . '</a>', esc_url( $email_link, array( 'mailto' ) ), esc_html( $content ) );
     119        return sprintf( '<a href="%s">' . $title . '</a>', esc_url( $email_link, array( 'mailto' ) ), esc_html( $content ) );
    121120    } );
    122121}
    123122
    124123/**
    125  * AJAX call for installing recommended plugins.
     124 * Pretty Search URL
    126125 */
    127 add_action( 'wp_ajax_wowcore_install_recommended_plugins', function () {
    128     try {
    129         if ( ! current_user_can( 'activate_plugins' ) ) {
    130             throw new ErrorException( __( 'Not enough permissions.' ) );
     126if ( carbon_get_theme_option( 'wowcore_encrypt_pretty_search_url' ) ) {
     127    add_action( 'template_redirect', function () {
     128        if ( is_search() && ! empty( $_GET['s'] ) ) {
     129            wp_redirect( home_url( "/search/" ) . urlencode( get_query_var( 's' ) ) );
     130            exit();
    131131        }
    132 
    133         $plugins = explode( ',', sanitize_text_field( $_POST['plugins'] ) );
    134 
    135         foreach ( $plugins as $plugin_data ) {
    136             $plugin_data = explode( '---', $plugin_data );
    137             $provider    = $plugin_data[0];
    138             $plugin_slug = $plugin_data[1];
    139 
    140             if ( ! wowcore_is_plugin_installed( $plugin_slug ) ) {
    141                 wowcore_download_plugin( $plugin_slug, $provider );
    142                 wowcore_extract_zip( WP_PLUGIN_DIR . '/' . $plugin_slug . '.zip', WP_PLUGIN_DIR );
    143             }
    144         }
    145 
    146         echo json_encode( [
    147             'success' => true,
    148         ] );
    149     } catch ( Exception $e ) {
    150         echo json_encode( [
    151             'success' => false,
    152             'message' => $e->getMessage(),
    153         ] );
    154     }
    155 
    156     wp_die();
    157 } );
     132    } );
     133}
  • wowholic-core/trunk/includes/actions/redirects.php

    r2645312 r3231152  
    44 * Redirect selected items (categories/tags/author pages).
    55 */
    6 if ( count( carbon_get_theme_option( 'wowcore_redirects_home' ) ) > 0 ) {
     6if ( count( carbon_get_theme_option( 'wowcore_redirects_home' ) ?? [] ) > 0 ) {
    77    add_action( 'template_redirect', function () {
    8         $redirects_home_field = carbon_get_theme_option( 'wowcore_redirects_home' );
     8        $redirects_home_field = carbon_get_theme_option( 'wowcore_redirects_home' ) ?: [];
    99        foreach ( $redirects_home_field as $type ) {
    10             if ( call_user_func( 'is_' . $type ) ) {
    11                 wp_redirect( '/', 301 );
     10            if ( ($type === 'search' && is_search()) || (function_exists( 'is_' . $type ) && call_user_func( 'is_' . $type )) ) {
     11                wp_redirect( home_url(), 301 );
     12                exit;
    1213            }
    1314        }
  • wowholic-core/trunk/includes/actions/tinymce.php

    r2645312 r3231152  
    6262    }
    6363}
     64
     65/**
     66 * Force TinyMCE second row to show if wp_adv is unchecked
     67 */
     68add_filter( 'tiny_mce_before_init', function ( $init ) {
     69    $remove_buttons = carbon_get_theme_option( 'wowcore_remove_tinymce_buttons' ) ?? [];
     70
     71    if ( in_array( 'wp_adv', $remove_buttons ) ) {
     72        $init['wordpress_adv_hidden'] = false;
     73    }
     74
     75    return $init;
     76} );
     77
     78/*
     79 *  Remove TinyMCE headlines
     80 */
     81if ( carbon_get_theme_option( 'wowcore_remove_tinymce_headlines' ) ) {
     82    $headlines_to_remove = carbon_get_theme_option( 'wowcore_remove_tinymce_headlines' );
     83
     84    add_filter( 'tiny_mce_before_init', function ( $init_array ) use ( $headlines_to_remove ) {
     85        $default_formats = [
     86            'Paragraph=p',
     87            'Heading 1=h1',
     88            'Heading 2=h2',
     89            'Heading 3=h3',
     90            'Heading 4=h4',
     91            'Heading 5=h5',
     92            'Heading 6=h6',
     93            'Preformatted=pre',
     94        ];
     95
     96        $filtered_formats = array_filter( $default_formats, function ( $format ) use ( $headlines_to_remove ) {
     97            foreach ( $headlines_to_remove as $headline ) {
     98                if ( str_contains( $format, $headline ) ) {
     99                    return false;
     100                }
     101            }
     102
     103            return true;
     104        } );
     105
     106
     107        $init_array['block_formats'] = implode( ';', $filtered_formats );
     108
     109        return $init_array;
     110    } );
     111}
  • wowholic-core/trunk/includes/settings-page.php

    r3230593 r3231152  
    1313             ->set_default_value( true ),
    1414        Field::make( 'checkbox', 'wowcore_disable_default_post_type', __( 'Disable default Post type' ) )
    15             ->set_default_value( true ),
     15            ->set_default_value( true ),
    1616        Field::make( 'checkbox', 'wowcore_disable_comments', __( 'Disable comments' ) )
    17             ->set_default_value( true ),
     17            ->set_default_value( true ),
    1818        Field::make( 'checkbox', 'wowcore_hide_widgets_page', __( 'Hide Widgets page' ) )
    1919             ->set_default_value( true ),
    2020        Field::make( 'checkbox', 'wowcore_encrypt_email_shortcode', __( 'Enable [email] shortcode for encrypting addresses' ) )
     21             ->set_default_value( true ),
     22        Field::make( 'checkbox', 'wowcore_encrypt_pretty_search_url', __( 'Pretty Search URL' ) )
    2123             ->set_default_value( true ),
    2224        Field::make( 'select', 'wowcore_upload_size_limit', __( 'Upload size limit' ) )
     
    3133             ->set_default_value( 256 )
    3234             ->set_help_text( 'Hosting provider size limit: ' . wowcore_get_hosting_max_filesize() . '. <a href="' . admin_url( 'site-health.php?tab=debug' ) . '">View more server details</a>' ),
    33         Field::make( 'html', 'wowcore_install_plugins', __( 'Install recommended plugins' ) )
    34              ->set_html( 'wowcore_get_install_plugins_html' ),
    3535    ];
    3636
     
    4242                 'date'     => 'Date archives',
    4343                 'author'   => 'Author pages',
     44                 'search'   => 'Search results',
    4445             ] )
    45              ->set_default_value( array( 'category', 'tag', 'date', 'author' ) ),
     46             ->set_default_value( array( 'category', 'tag', 'date', 'author', 'search' ) ),
    4647        Field::make( 'checkbox', 'wowcore_redirect_media', __( 'Redirect attachment pages to the file URL' ) ),
    4748    ];
     
    107108            Field::make( 'checkbox', 'wowcore_hide_acf_menu', __( 'Hide ACF menu for non-admins' ) ),
    108109        ];
     110
     111        if ( acf_get_setting( 'pro' ) ) {
     112            $acf_header_template = '
     113            <% if (flexible_content_name) { %>
     114                <%- flexible_content_name %>
     115            <% } %>
     116            ';
     117
     118            $acf_fields[] = Field::make( 'complex', 'wowcore_acf_flexible_contents', __( 'Add label next to Flexible Content Layout name' ) )
     119                                 ->setup_labels( [
     120                                     'plural_name'   => 'Flexible Contents',
     121                                     'singular_name' => 'Flexible Content',
     122                                 ] )
     123                                 ->add_fields( [
     124                                     Field::make( 'text', 'flexible_content_name', __( 'Flexible Content Name' ) )
     125                                          ->set_width( 50 ),
     126                                     Field::make( 'text', 'title_field_name', __( 'Title Field Name' ) )
     127                                          ->set_width( 50 ),
     128                                 ] )
     129                                 ->set_header_template( $acf_header_template )
     130                                 ->set_collapsed( true );
     131        }
    109132
    110133        $container->add_tab( __( 'ACF' ), $acf_fields );
     
    181204                     'indent',
    182205                 ] ),
     206            Field::make( 'set', 'wowcore_remove_tinymce_headlines', __( 'Headlines to remove' ) )
     207                 ->set_options( [
     208                     'h1'  => 'H1',
     209                     'h2'  => 'H2',
     210                     'h3'  => 'H3',
     211                     'h4'  => 'H4',
     212                     'h5'  => 'H5',
     213                     'h6'  => 'H6',
     214                     'pre' => 'Preformatted',
     215                 ] )
     216                 ->set_default_value( [
     217                     'pre',
     218                 ] ),
    183219        ];
    184220
  • wowholic-core/trunk/includes/utils.php

    r2645312 r3231152  
    11<?php
    2 
    3 /**
    4  * Get the recommended plugins
    5  *
    6  * @return string[][]
    7  */
    8 function wowcore_get_recommended_plugins(): array {
    9     return [
    10         [
    11             'provider' => 'wp',
    12             'slug'     => 'classic-editor',
    13             'name'     => 'Classic Editor',
    14         ],
    15         [
    16             'provider' => 'wp',
    17             'slug'     => 'duplicate-page',
    18             'name'     => 'Duplicate Page',
    19         ],
    20         [
    21             'provider' => 'wp',
    22             'slug'     => 'redirection',
    23             'name'     => 'Redirection',
    24         ],
    25         [
    26             'provider' => 'wp',
    27             'slug'     => 'svg-support',
    28             'name'     => 'SVG Support',
    29         ],
    30         [
    31             'provider' => 'wp',
    32             'slug'     => 'updraftplus',
    33             'name'     => 'UpdraftPlus',
    34         ],
    35         [
    36             'provider' => 'wp',
    37             'slug'     => 'webp-express',
    38             'name'     => 'WebP Express',
    39         ],
    40         [
    41             'provider' => 'wp',
    42             'slug'     => 'wordpress-seo',
    43             'name'     => 'Yoast SEO',
    44         ],
    45     ];
    46 }
    47 
    48 /**
    49  * Download a plugin to the /plugins directory
    50  *
    51  * @param $plugin_slug
    52  * @param $provider
    53  */
    54 function wowcore_download_plugin( $plugin_slug, $provider ) {
    55     if ( $provider === 'wp' ) {
    56         $filename = 'https://downloads.wordpress.org/plugin/' . $plugin_slug . '.zip';
    57     }
    58 
    59     file_put_contents( WP_PLUGIN_DIR . '/' . $plugin_slug . '.zip', file_get_contents( $filename ) );
    60 }
    61 
    62 /**
    63  * Extract zip file to a given location
    64  *
    65  * @param $file_location
    66  * @param $extract_to
    67  */
    68 function wowcore_extract_zip( $file_location, $extract_to ) {
    69     if ( ! file_exists( $file_location ) ) {
    70         return;
    71     }
    72 
    73     $zip      = new ZipArchive;
    74     $did_open = $zip->open( $file_location );
    75 
    76     if ( $did_open === true ) {
    77         $zip->extractTo( $extract_to );
    78         $zip->close();
    79         unlink( $file_location );
    80     }
    81 }
    82 
    83 /**
    84  * Check if a plugin is installed (not necessarily activated)
    85  *
    86  * @param $plugin_slug
    87  *
    88  * @return bool
    89  */
    90 function wowcore_is_plugin_installed( $plugin_slug ): bool {
    91     if ( ! function_exists( 'is_plugin_active' ) ) {
    92         include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
    93     }
    94 
    95     foreach ( get_plugins() as $installed_plugin_slug => $installed_plugin_data ) {
    96         if ( strpos( $installed_plugin_slug, $plugin_slug ) !== false ) {
    97             return true;
    98         }
    99     }
    100 
    101     return false;
    102 }
    103 
    1042/**
    1053 * Check if a plugin is active passing only the slug
     
    14341    return $ini_size;
    14442}
    145 
    146 /**
    147  * Get install plugins html
    148  *
    149  * @return false|string
    150  */
    151 function wowcore_get_install_plugins_html() {
    152     ob_start();
    153     $all_installed = true; ?>
    154 
    155     <strong><?php _e( 'Install recommended plugins' ) ?></strong>
    156     <ul id="recommended-plugins"> <?php
    157         foreach ( wowcore_get_recommended_plugins() as $plugin ) : ?>
    158             <li> <?php
    159                 if ( ! wowcore_is_plugin_installed( $plugin['slug'] ) ) :
    160                     $all_installed = false; ?>
    161                     <input id="wowcore-<?php echo esc_attr( $plugin['slug'] ); ?>" type="checkbox"
    162                            value="<?php echo esc_attr( $plugin['provider'] ); ?>---<?php echo esc_attr( $plugin['slug'] ); ?>"
    163                            name="plugins">
    164                     <label for="wowcore-<?php echo esc_attr( $plugin['slug'] ); ?>"><?php echo esc_html( $plugin['name'] ); ?></label> <?php
    165                 else : ?>
    166                     <p><?php echo esc_html( $plugin['name'] ); ?> <?php _e( 'is already installed' ) ?>.</p> <?php
    167                 endif; ?>
    168             </li> <?php
    169         endforeach; ?>
    170     </ul> <?php
    171 
    172     if ( ! $all_installed ) : ?>
    173         <button id="wowcore-install-recommended-plugins"
    174                 class="button button-primary button-large"><?php _e( 'Install' ) ?></button>
    175         <div class="wowcore-install-plugins-wait">
    176             <span class="spinner is-active"></span>
    177             <?php _e( 'Downloading and installing plugins. Please wait...' ) ?>
    178         </div> <?php
    179     endif;
    180 
    181     return ob_get_clean();
    182 }
  • wowholic-core/trunk/readme.txt

    r3230593 r3231152  
    44License: GPLv3
    55License URI: http://www.gnu.org/licenses/gpl.html
    6 Tags: utility, productivity, efficiency, custom themes, development, frontend
     6Tags: utility, productivity, efficiency, custom themes, development
    77Requires at least: 5.6
    88Tested up to: 6.7.1
    9 Stable tag: 1.0.9
     9Stable tag: 1.1.0
    1010Requires PHP: 7.0
    1111
     
    3434    * Remove emoji detection script and styles
    3535* Disable Theme & Plugin Editors, Widgets Admin Page, Default Post Type and Comments
    36 * Batch download & install recommended plugins
    3736* Set up some default redirections (archives, attachment pages...)
    3837* Set up a visual grid on different breakpoints for debugging layout styles
     
    7776== Changelog ==
    7877
     78= 1.1.0 =
     79Release Date: January 29th, 2025
     80
     81* Remove Install recommended plugins
     82* ACF add label next to Flexible Content Layout name
     83* Pretty search url
     84* Add option to redirect search results page
     85* Add option to remove TinyMCE headlines
     86* Force TinyMCE second row to show if "Second row toggle" is unchecked
     87
    7988= 1.0.9 =
    8089Release Date: January 28th, 2025
  • wowholic-core/trunk/wowholic-core.php

    r3230593 r3231152  
    44 * Plugin URI: https://github.com/Wowholic/CORE
    55 * Description: Utility functions and options for common tasks in WordPress.
    6  * Version: 1.0.9
     6 * Version: 1.1.0
    77 * Author: Wowholic
    88 * Author URI: https://wowholic.com
Note: See TracChangeset for help on using the changeset viewer.