This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| Plugin Name: Global Styles Builder for GenerateBlocks | |
| Plugin URI: https://timtaricco.com | |
| Description: A plugin to create and manage global styles for GenerateBlocks. | |
| Version: 07.23.24 | |
| Author: Tim Taricco | |
| Author URI: https://timtaricco.com | |
| License: GPL2 | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*** Instructions Panel for Posts ***/ | |
| function wsv_post_instructions_panel() { | |
| add_meta_box( | |
| 'wsv-post-instructions-panel', | |
| 'Post Instructions', | |
| 'wsv_post_instructions_panel_display_callback', | |
| 'post', | |
| 'side', | |
| 'high' | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*** Redirect logged in users from Login page to Dashboard automatically ***/ | |
| add_action('template_redirect', 'redirect_logged_in_users'); | |
| function redirect_logged_in_users() { | |
| // Check if the user is logged in | |
| if (is_user_logged_in()) { | |
| // Get the current URL | |
| $current_url = home_url($_SERVER['REQUEST_URI']); | |
| // Define the URL to check |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*** Remove frontend WordPress admin bar for users other than Administrators ***/ | |
| add_action('after_setup_theme', 'remove_admin_bar'); | |
| function remove_admin_bar() { | |
| if (!current_user_can('administrator') && !is_admin()) { | |
| show_admin_bar(false); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*** Redirect to homepage on logout ***/ | |
| add_action('check_admin_referer', 'logout_without_confirm', 10, 2); | |
| function logout_without_confirm($action, $result) | |
| { | |
| if ($action == "log-out" && !isset($_GET['_wpnonce'])) { | |
| $redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : home_url(); | |
| $location = str_replace('&', '&', wp_logout_url($redirect_to)); | |
| header("Location: $location"); | |
| exit(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Add taxonomy filter dropdowns to the Resources CPT admin page | |
| function wsv_resources_category_filter() { | |
| global $typenow; | |
| if ($typenow == 'resources') { | |
| $taxonomies = array('resource-type'); | |
| if (!empty($taxonomies)) { | |
| foreach ($taxonomies as $taxonomy) { | |
| $selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : ''; | |
| $info_taxonomy = get_taxonomy($taxonomy); | |
| wp_dropdown_categories(array( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*** | |
| 1 - Find and replace cpt_name with CPT name using underscore | |
| 2 - Find and replace cpt-name with CPT name using a dash (if CPT name uses a dash) | |
| –––––––––––––––––––––––––––––––––––––––––––––––––– ***/ | |
| /* Load editor notice for CPT */ | |
| function wsv_cpt_name_notice_script() { | |
| // Ensure we are on the admin screen to prevent errors on the front end | |
| if (is_admin()) { | |
| // Get the current screen object |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*** Set default editor content for Video CPT using a specific Local Pattern | |
| –––––––––––––––––––––––––––––––––––––––––––––––––– ***/ | |
| function add_or_replace_content_with_gb_template_for_video_posts($data, $postarr) { | |
| // Only target the 'video' post type | |
| if ($data['post_type'] == 'video') { | |
| // Define your gblocks_templates Post ID | |
| $gb_template_post_id = 5593; // Replace 5501 with your actual gblocks_templates Post ID | |
| // Get the content of the gblocks_templates post | |
| $gb_template_post = get_post($gb_template_post_id); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*** TODAY VERSION - Custom function for making the /matchday/ URL redirect to the next upcoming match URL | |
| –––––––––––––––––––––––––––––––––––––––––––––––––– ***/ | |
| add_action('template_redirect', 'redirect_to_next_match'); | |
| function redirect_to_next_match() { | |
| if (is_page('matchday')) { // Check if the current page is /matchday/ | |
| $today = date('Ymd'); // Get today's date in ACF's preferred format. | |
| $args = array( | |
| 'post_type' => 'match', // Your custom post type. | |
| 'posts_per_page' => 1, // We only need the next match. | |
| 'meta_key' => 'match_date', // The ACF field key for the match date. |