This file contains 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
// inspired by: https://gist.github.com/rveitch/9018669face1686e74aaa68026856f36 | |
// add iitle to CPTs which doesn't provide a title (useful for the relationship field (https://www.advancedcustomfields.com/resources/relationship/)) | |
function sync_acf_post_title($post_id, $post, $update) { | |
$post_type = get_post_type($post_id); | |
// check for the current CPT | |
if($post_type === "cpt_name_1") { | |
This file contains 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: Convert ACF PHP to JSON | |
* Description: Convert Advanced Custom Fields Pro configuration from PHP to JSON. | |
*/ | |
namespace ConvertAcfPhpToJson; | |
/** | |
* Add submenu item under 'Custom Fields' |
This file contains 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_filter( 'acf/load_field/name=flex_layout', __CLASS__ . '::craft_content_layouts' ); | |
static function craft_content_layouts( $field ) { | |
// Remove the layouts | |
// that are named in this list | |
$remove_list = [ | |
'paragraph', | |
'banner', |
This file contains 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 | |
$reusable_checkbox_field = array( | |
'type' => 'checkbox', | |
'choices' => array( | |
'red' => __('Red', THEME_SLUG), | |
'white' => __('White', THEME_SLUG), | |
'blue' => __('Blue', THEME_SLUG), | |
), | |
); |
This file contains 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 | |
/** | |
* Shortocde for displaying terms filter and results on page | |
*/ | |
function vb_filter_posts_sc($atts) { | |
$a = shortcode_atts( array( | |
'tax' => 'post_tag', // Taxonomy | |
'terms' => false, // Get specific taxonomy terms only | |
'active' => false, // Set active term by ID |
This file contains 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 | |
/** | |
* Register custom query vars | |
* | |
* @param array $vars The array of available query variables | |
* | |
* @link https://codex.wordpress.org/Plugin_API/Filter_Reference/query_vars | |
*/ | |
function myplugin_register_query_vars( $vars ) { | |
$vars[] = 'key1'; |
This file contains 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 | |
/** | |
* Set a custom login page | |
* | |
* @param string $url Default login URL | |
* @param string $redirect Redirect URL on login | |
* @param bool $force_reauth Whether to force reauthorization | |
* @link https://developer.wordpress.org/reference/hooks/login_url/ | |
*/ | |
function frontend_login_url( $url, $redirect, $force_reauth ){ |
This file contains 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
//Setting Ajax handlers | |
add_action( 'wp_ajax_nopriv_get_author_info', array( $this, 'bps_get_author_info_cb' ) ); | |
add_action( 'wp_ajax_get_author_info', array( $this, 'bps_get_author_info_cb' ) ); | |
/** | |
* Function used to get author info for popup on article | |
*/ | |
public function bps_get_author_info_cb() { | |
global $coauthors_plus; | |
//Checking nonce |
This file contains 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 columns from Page section | |
// ------------------------------------------------------------- | |
function my_pages_columns( $defaults ) { | |
unset( $defaults['comments'] ); | |
unset( $defaults['author'] ); | |
unset( $defaults['tags'] ); | |
unset( $defaults['date'] ); | |
// WordPress SEO | |
unset( $defaults['wpseo-title'] ); |