function reset_meta_box_order_for_all_users() {
// Get all users
$users = get_users();
foreach ($users as $user) {
// Get the user ID
$user_id = $user->ID;
// Get all meta keys for the user that start with 'meta-box-order_'
global $wpdb;
$meta_keys = $wpdb->get_col($wpdb->prepare("
SELECT meta_key
FROM {$wpdb->prefix}usermeta
WHERE user_id = %d
AND meta_key LIKE 'meta-box-order_%'
", $user_id));
// Update each meta key to have all values set to 'normal'
foreach ($meta_keys as $meta_key) {
$meta_value = get_user_meta($user_id, $meta_key, true);
if ($meta_value) {
// Update the order from any existing value to 'normal'
$meta_value = array_map(function($v) { return 'normal'; }, $meta_value);
update_user_meta($user_id, $meta_key, $meta_value);
}
}
}
}
add_action('init', function() {
if (current_user_can('administrator')) { // Ensure only administrators can trigger this
reset_meta_box_order_for_all_users();
}
});
//START POPUP
// Enqueue Carclew Popup script and styles in the footer
function enqueue_carclew_popup_script() {
include get_template_directory() . '/popup.php';
}
add_action('wp_footer', 'enqueue_carclew_popup_script');
//END POPUP
function custom_program_columns($columns) {
$columns['content_categories'] = 'Content Categories';
return $columns;
}
add_filter('manage_program_posts_columns', 'custom_program_columns');
function display_custom_program_column($column_name, $post_id) {
if ($column_name === 'content_categories') {
$categories = get_field('content_categories', $post_id);
if ($categories) {
$category_names = array();
foreach ($categories as $category) {
$category_names[] = $category->name;
}
echo esc_html(implode(', ', $category_names));
} else {
echo '-';
}
}
}
add_action('manage_program_posts_custom_column', 'display_custom_program_column', 10, 2);
function acf_posts_where( $where ) {
$where = str_replace( "( wp_postmeta.meta_key = 'include_in_feed' AND wp_postmeta.meta_value = 'CUSTOMSQL' )", "
(
wp_posts.post_type IN ('post')
and wp_posts.post_date > DATE_ADD(NOW(), INTERVAL -1 MONTH)
and wp_postmeta.meta_key = 'include_in_feed' AND wp_postmeta.meta_value = '1'
)
OR
(
wp_posts.post_type IN ('program')
AND wp_postmeta.meta_key = 'dates_end_date'
AND date_format(NOW(), '%Y%m%d') <= wp_postmeta.meta_value
)
", $where );
return $where;
}
add_filter( 'posts_where', 'acf_posts_where' );
add_action('init', 'my_theme_remove_post_type_support');
function my_theme_remove_post_type_support() {
remove_post_type_support('post', 'excerpt');
remove_post_type_support('post', 'comments' );
remove_post_type_support('page', 'excerpt');
remove_post_type_support('page', 'comments' );
remove_post_type_support('program', 'excerpt');
remove_post_type_support('program', 'comments' );
remove_post_type_support('event', 'excerpt');
remove_post_type_support('event', 'comments' );
remove_post_type_support('landing', 'excerpt');
remove_post_type_support('landing', 'comments' );
remove_post_type_support('people', 'excerpt');
remove_post_type_support('people', 'comments' );
}
add_action('admin_head', 'my_custom_fonts');
function my_custom_fonts() {
echo '';
}
function wpb_custom_new_menu() {
register_nav_menu('my-custom-menu',__( 'Top Menu' ));
register_nav_menu('my-custom-menu',__( 'Footer Menu' ));
}
add_action( 'init', 'wpb_custom_new_menu' );
add_action( 'admin_enqueue_scripts', 'my_admin_style');
function my_admin_style() {
wp_enqueue_style( 'admin-style', get_stylesheet_directory_uri() . '/admin-style.css' );
}
function str_replace_first($from, $to, $content)
{
$from = '/'.preg_quote($from, '/').'/';
return preg_replace($from, $to, $content, 1);
}
function startsWith( $haystack, $needle ) {
$length = strlen( $needle );
return substr( $haystack, 0, $length ) === $needle;
}
function revcon_change_post_label() {
global $menu;
global $submenu;
$menu[5][0] = 'News';
$submenu['edit.php'][5][0] = 'News';
$submenu['edit.php'][10][0] = 'Add News';
$submenu['edit.php'][16][0] = 'News Tags';
}
function custom_post_types() {
// Set UI labels for Custom Post Type
$labels = array(
'name' => _x( 'Programs', 'Post Type General Name', 'twentytwenty' ),
'singular_name' => _x( 'Program', 'Post Type Singular Name', 'twentytwenty' ),
'menu_name' => __( 'Programs', 'twentytwenty' ),
'all_items' => __( 'All Programs', 'twentytwenty' ),
'view_item' => __( 'View Program', 'twentytwenty' ),
'add_new_item' => __( 'Add New Program', 'twentytwenty' ),
'add_new' => __( 'Add New', 'twentytwenty' ),
'edit_item' => __( 'Edit Program', 'twentytwenty' ),
'update_item' => __( 'Update Program', 'twentytwenty' ),
'search_items' => __( 'Search Program', 'twentytwenty' ),
'not_found' => __( 'Not Found', 'twentytwenty' ),
'not_found_in_trash' => __( 'Not found in Trash', 'twentytwenty' ),
);
// Set other options for Custom Post Type
$args_Programs = array(
'label' => __( 'Programs', 'twentytwenty' ),
'description' => __( 'Programs', 'twentytwenty' ),
'labels' => $labels,
// Features this CPT supports in Post Editor
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
/* A hierarchical CPT is like Pages and can have
* Parent and child items. A non-hierarchical CPT
* is like Posts.
*/
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_icon' => 'dashicons-tickets-alt',
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
'show_in_rest' => true,
);
// Set UI labels for Custom Post Type
$labels = array(
'name' => _x( 'People', 'Post Type General Name', 'twentytwenty' ),
'singular_name' => _x( 'People', 'Post Type Singular Name', 'twentytwenty' ),
'menu_name' => __( 'People', 'twentytwenty' ),
'all_items' => __( 'All People', 'twentytwenty' ),
'view_item' => __( 'View People', 'twentytwenty' ),
'add_new_item' => __( 'Add New People', 'twentytwenty' ),
'add_new' => __( 'Add New', 'twentytwenty' ),
'edit_item' => __( 'Edit People', 'twentytwenty' ),
'update_item' => __( 'Update People', 'twentytwenty' ),
'search_items' => __( 'Search People', 'twentytwenty' ),
'not_found' => __( 'Not Found', 'twentytwenty' ),
'not_found_in_trash' => __( 'Not found in Trash', 'twentytwenty' ),
);
// Set other options for Custom Post Type
$args_People = array(
'label' => __( 'People', 'twentytwenty' ),
'description' => __( 'People', 'twentytwenty' ),
'labels' => $labels,
// Features this CPT supports in Post Editor
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
/* A hierarchical CPT is like Pages and can have
* Parent and child items. A non-hierarchical CPT
* is like Posts.
*/
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_icon' => 'dashicons-admin-users',
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
'show_in_rest' => true,
);
$labelsLanding = array(
'name' => _x( 'Landing Pages', 'Post Type General Name', 'twentytwenty' ),
'singular_name' => _x( 'Landing Page', 'Post Type Singular Name', 'twentytwenty' ),
'menu_name' => __( 'Landing Pages', 'twentytwenty' ),
'all_items' => __( 'All Landing Pages', 'twentytwenty' ),
'view_item' => __( 'View Landing Page', 'twentytwenty' ),
'add_new_item' => __( 'Add New Landing Page', 'twentytwenty' ),
'add_new' => __( 'Add New', 'twentytwenty' ),
'edit_item' => __( 'Edit Landing Page', 'twentytwenty' ),
'update_item' => __( 'Update Landing Page', 'twentytwenty' ),
'search_items' => __( 'Search Landing Pages', 'twentytwenty' ),
'not_found' => __( 'Not Found', 'twentytwenty' ),
'not_found_in_trash' => __( 'Not found in Trash', 'twentytwenty' ),
);
// Set other options for Custom Post Type
$args_landings = array(
'label' => __( 'Landing Pages', 'twentytwenty' ),
'description' => __( 'Landing Pages', 'twentytwenty' ),
'labels' => $labelsLanding,
// Features this CPT supports in Post Editor
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
/* A hierarchical CPT is like Pages and can have
* Parent and child items. A non-hierarchical CPT
* is like Posts.
*/
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-format-aside',
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
'show_in_rest' => true,
);
$labelsEvent = array(
'name' => _x( 'Event', 'Post Type General Name', 'twentytwenty' ),
'singular_name' => _x( 'Event', 'Post Type Singular Name', 'twentytwenty' ),
'menu_name' => __( 'Events', 'twentytwenty' ),
'all_items' => __( 'All Events', 'twentytwenty' ),
'view_item' => __( 'View Event', 'twentytwenty' ),
'add_new_item' => __( 'Add New Event', 'twentytwenty' ),
'add_new' => __( 'Add New', 'twentytwenty' ),
'edit_item' => __( 'Edit Event', 'twentytwenty' ),
'update_item' => __( 'Update Event', 'twentytwenty' ),
'search_items' => __( 'Search Events', 'twentytwenty' ),
'not_found' => __( 'Not Found', 'twentytwenty' ),
'not_found_in_trash' => __( 'Not found in Trash', 'twentytwenty' ),
);
// Set other options for Custom Post Type
$args_Event = array(
'label' => __( 'Events', 'twentytwenty' ),
'description' => __( 'Events', 'twentytwenty' ),
'labels' => $labelsEvent,
// Features this CPT supports in Post Editor
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
/* A hierarchical CPT is like Pages and can have
* Parent and child items. A non-hierarchical CPT
* is like Posts.
*/
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-calendar-alt',
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
'show_in_rest' => true,
);
// Registering your Custom Post Type
register_post_type( 'program', $args_Programs );
register_post_type( 'landing', $args_landings );
register_post_type( 'event', $args_Event );
register_post_type( 'people', $args_People );
}
add_action( 'init', 'custom_post_types', 0 );
function revcon_change_post_object() {
global $wp_post_types;
$labels = &$wp_post_types['post']->labels;
$labels->name = 'News';
$labels->singular_name = 'News';
$labels->add_new = 'Add News';
$labels->add_new_item = 'Add News';
$labels->edit_item = 'Edit News';
$labels->new_item = 'News';
$labels->view_item = 'View News';
$labels->search_items = 'Search News';
$labels->not_found = 'No News found';
$labels->not_found_in_trash = 'No News found in Trash';
$labels->all_items = 'All News';
$labels->menu_name = 'News';
$labels->name_admin_bar = 'News';
}
add_action( 'admin_menu', 'revcon_change_post_label' );
add_action( 'init', 'revcon_change_post_object' );
// add a link to the WP Toolbar
function custom_toolbar_link($wp_admin_bar) {
$args = array(
'id' => 'edithomepage',
'title' => 'Edit Home Page',
'href' => 'https://carclew.com.au/wp-admin/post.php?post=147&action=edit',
'meta' => array(
'class' => 'wpbeginner',
'title' => 'Edit Home Page'
)
);
$wp_admin_bar->add_node($args);
}
add_action('admin_bar_menu', 'custom_toolbar_link', 999);
// Disable support for comments and trackbacks in post types
function disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
if(post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
remove_post_type_support($post_type, 'trackbacks');
}
}
}
add_action('admin_init', 'disable_comments_post_types_support');
// Close comments on the front-end
function disable_comments_status() {
return false;
}
add_filter('comments_open', 'disable_comments_status', 20, 2);
add_filter('pings_open', 'disable_comments_status', 20, 2);
// Hide existing comments
function disable_comments_hide_existing_comments($comments) {
return array();
}
add_filter('comments_array', 'disable_comments_hide_existing_comments', 10, 2);
// Remove comments page in menu
function disable_comments_admin_menu() {
remove_menu_page('edit-comments.php');
}
add_action('admin_menu', 'disable_comments_admin_menu');
// Redirect any user trying to access comments page
function disable_comments_admin_menu_redirect() {
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
}
add_action('admin_init', 'disable_comments_admin_menu_redirect');
// Remove comments metabox from dashboard
function disable_comments_dashboard() {
remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');
}
add_action('admin_init', 'disable_comments_dashboard');
// Remove comments links from admin bar
function disable_comments_admin_bar() {
if (is_admin_bar_showing()) {
remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
}
}
add_action('init', 'disable_comments_admin_bar');
?>
https://carclew.com.au/post-sitemap.xml
2023-04-27T06:24:54+00:00
https://carclew.com.au/page-sitemap.xml
2026-05-31T12:48:34+00:00
https://carclew.com.au/category-sitemap.xml
2023-04-27T06:24:54+00:00
https://carclew.com.au/post_tag-sitemap.xml
2021-07-05T00:05:33+00:00
https://carclew.com.au/author-sitemap.xml
2025-09-02T05:30:09+00:00