Changeset 3231152
- Timestamp:
- 01/29/2025 09:29:59 AM (12 months ago)
- Location:
- wowholic-core/trunk
- Files:
-
- 10 edited
-
assets/css/main.css (modified) (1 diff)
-
assets/js/main.js (modified) (1 diff)
-
includes/actions/acf.php (modified) (1 diff)
-
includes/actions/general.php (modified) (2 diffs)
-
includes/actions/redirects.php (modified) (1 diff)
-
includes/actions/tinymce.php (modified) (1 diff)
-
includes/settings-page.php (modified) (5 diffs)
-
includes/utils.php (modified) (2 diffs)
-
readme.txt (modified) (3 diffs)
-
wowholic-core.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wowholic-core/trunk/assets/css/main.css
r2645312 r3231152 2 2 cursor: pointer; 3 3 } 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 1 1 document.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 });37 2 }); -
wowholic-core/trunk/includes/actions/acf.php
r2645312 r3231152 33 33 } ); 34 34 } 35 36 /** 37 * Add label next to Flexible Content Layout name 38 */ 39 if ( 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 97 97 if ( carbon_get_theme_option( 'wowcore_encrypt_email_shortcode' ) ) { 98 98 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 ), $atts104 );99 $atts = array_change_key_case( (array) $atts, CASE_LOWER ); 100 $array_atts = shortcode_atts( 101 array( 102 'title' => '', 103 ), $atts 104 ); 105 105 106 106 if ( ! is_email( $content ) ) { … … 108 108 } 109 109 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 } 116 115 117 116 $content = antispambot( $content ); 118 117 $email_link = sprintf( 'mailto:%s', $content ); 119 118 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 ) ); 121 120 } ); 122 121 } 123 122 124 123 /** 125 * AJAX call for installing recommended plugins.124 * Pretty Search URL 126 125 */ 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.' ) ); 126 if ( 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(); 131 131 } 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 4 4 * Redirect selected items (categories/tags/author pages). 5 5 */ 6 if ( count( carbon_get_theme_option( 'wowcore_redirects_home' ) ) > 0 ) {6 if ( count( carbon_get_theme_option( 'wowcore_redirects_home' ) ?? [] ) > 0 ) { 7 7 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' ) ?: []; 9 9 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; 12 13 } 13 14 } -
wowholic-core/trunk/includes/actions/tinymce.php
r2645312 r3231152 62 62 } 63 63 } 64 65 /** 66 * Force TinyMCE second row to show if wp_adv is unchecked 67 */ 68 add_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 */ 81 if ( 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 13 13 ->set_default_value( true ), 14 14 Field::make( 'checkbox', 'wowcore_disable_default_post_type', __( 'Disable default Post type' ) ) 15 ->set_default_value( true ),15 ->set_default_value( true ), 16 16 Field::make( 'checkbox', 'wowcore_disable_comments', __( 'Disable comments' ) ) 17 ->set_default_value( true ),17 ->set_default_value( true ), 18 18 Field::make( 'checkbox', 'wowcore_hide_widgets_page', __( 'Hide Widgets page' ) ) 19 19 ->set_default_value( true ), 20 20 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' ) ) 21 23 ->set_default_value( true ), 22 24 Field::make( 'select', 'wowcore_upload_size_limit', __( 'Upload size limit' ) ) … … 31 33 ->set_default_value( 256 ) 32 34 ->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' ),35 35 ]; 36 36 … … 42 42 'date' => 'Date archives', 43 43 'author' => 'Author pages', 44 'search' => 'Search results', 44 45 ] ) 45 ->set_default_value( array( 'category', 'tag', 'date', 'author' ) ),46 ->set_default_value( array( 'category', 'tag', 'date', 'author', 'search' ) ), 46 47 Field::make( 'checkbox', 'wowcore_redirect_media', __( 'Redirect attachment pages to the file URL' ) ), 47 48 ]; … … 107 108 Field::make( 'checkbox', 'wowcore_hide_acf_menu', __( 'Hide ACF menu for non-admins' ) ), 108 109 ]; 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 } 109 132 110 133 $container->add_tab( __( 'ACF' ), $acf_fields ); … … 181 204 'indent', 182 205 ] ), 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 ] ), 183 219 ]; 184 220 -
wowholic-core/trunk/includes/utils.php
r2645312 r3231152 1 1 <?php 2 3 /**4 * Get the recommended plugins5 *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 directory50 *51 * @param $plugin_slug52 * @param $provider53 */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 location64 *65 * @param $file_location66 * @param $extract_to67 */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_slug87 *88 * @return bool89 */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 104 2 /** 105 3 * Check if a plugin is active passing only the slug … … 143 41 return $ini_size; 144 42 } 145 146 /**147 * Get install plugins html148 *149 * @return false|string150 */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"> <?php157 foreach ( wowcore_get_recommended_plugins() as $plugin ) : ?>158 <li> <?php159 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> <?php165 else : ?>166 <p><?php echo esc_html( $plugin['name'] ); ?> <?php _e( 'is already installed' ) ?>.</p> <?php167 endif; ?>168 </li> <?php169 endforeach; ?>170 </ul> <?php171 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> <?php179 endif;180 181 return ob_get_clean();182 } -
wowholic-core/trunk/readme.txt
r3230593 r3231152 4 4 License: GPLv3 5 5 License URI: http://www.gnu.org/licenses/gpl.html 6 Tags: utility, productivity, efficiency, custom themes, development , frontend6 Tags: utility, productivity, efficiency, custom themes, development 7 7 Requires at least: 5.6 8 8 Tested up to: 6.7.1 9 Stable tag: 1. 0.99 Stable tag: 1.1.0 10 10 Requires PHP: 7.0 11 11 … … 34 34 * Remove emoji detection script and styles 35 35 * Disable Theme & Plugin Editors, Widgets Admin Page, Default Post Type and Comments 36 * Batch download & install recommended plugins37 36 * Set up some default redirections (archives, attachment pages...) 38 37 * Set up a visual grid on different breakpoints for debugging layout styles … … 77 76 == Changelog == 78 77 78 = 1.1.0 = 79 Release 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 79 88 = 1.0.9 = 80 89 Release Date: January 28th, 2025 -
wowholic-core/trunk/wowholic-core.php
r3230593 r3231152 4 4 * Plugin URI: https://github.com/Wowholic/CORE 5 5 * Description: Utility functions and options for common tasks in WordPress. 6 * Version: 1. 0.96 * Version: 1.1.0 7 7 * Author: Wowholic 8 8 * Author URI: https://wowholic.com
Note: See TracChangeset
for help on using the changeset viewer.