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 | |
| //add custom notification in WP Admin | |
| function general_admin_notice(){ | |
| global $pagenow; | |
| if ( $pagenow == 'post.php' ) { // add/edit pages/files as required | |
| //add any custom message here | |
| $current_user = wp_get_current_user(); | |
| $user_name = $current_user->user_firstname; | |
| echo '<div class="notice notice-warning"> | |
| <p>Hey <strong>'. $user_name . '.</strong> You are awesome!</p> |
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 | |
| //Remove white space at start and end and remove from ACF fields | |
| function my_acf_update_value( $value, $post_id, $field ) { | |
| if( is_string($value) ) { | |
| $value = rtrim($value); | |
| $value = ltrim($value); | |
| $value = preg_replace('/ /', '', $value); | |
| } | |
| return $value; | |
| } |
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 | |
| /** | |
| * Disable ACF on Frontend | |
| */ | |
| function disable_acf_on_frontend( $plugins ) { | |
| if ( is_admin() ) { | |
| return $plugins; | |
| } | |
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 | |
| //Add class to admin body if user is not an Administrator | |
| if( ! current_user_can('administrator') ) { | |
| add_filter( 'admin_body_class', 'rw_admin_only_body_class' ); | |
| function rw_admin_only_body_class( $classes ) | |
| { | |
| $classes = 'admin-readonly'; | |
| return $classes; | |
| } | |
| } |
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 | |
| // Update CSS within Admin Dashboard | |
| function admin_style() { | |
| wp_enqueue_style( 'admin-styles', get_template_directory_uri() . '/css/admin.min.css' ); | |
| //change filename and/or url as required | |
| } | |
| add_action( 'admin_enqueue_scripts', 'admin_style' ); //load on admin pages | |
| add_action('login_enqueue_scripts', 'admin_style'); //load on login page | |
| ?> |
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 | |
| //Hide given ACF fields on "my_cpt" post_type | |
| function my_custom_function() { | |
| global $current_screen; | |
| if ( 'my_cpt' == $current_screen->post_type ) { | |
| ?> | |
| <script> | |
| (function () { | |
| var x = document.querySelectorAll("a[data-key='field_5ea76a5ac9b48']"); | |
| //change data-key as required |
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
| <!--Accordion Section--> | |
| <?php | |
| /* | |
| * This is an example of ACF repeater field whose name is "Content Accordion" | |
| * and has sub fields: "Accordion Title" & "Accordion Content" | |
| */ | |
| $accordions = get_post_meta( get_the_ID(), 'content_accordion', TRUE ); | |
| if ( $accordions ) { | |
| ?> | |
| <div class="container"> |
NewerOlder