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
// get all field groups that have location User Add/Edit Form | |
$field_groups = acf_get_field_groups(array( 'user_form' => 'edit')); | |
$all_fields = array(); | |
foreach ($field_groups as $field_group){ | |
$fields = acf_get_fields($field_group['key']); | |
$all_fields = array_merge($all_fields, $fields); //get all user's fields together | |
} | |
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
add_shortcode( 'acf_registration', 'acf_registration' ); | |
function acf_registration() { | |
$args = array(); //arguments here | |
ob_start(); | |
acf_form( $args ); | |
$registration_form = ob_get_contents(); | |
ob_end_clean(); | |
return $registration_form; | |
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
//<div class="elementor-column"><div class="dce-acf-repater-"><div class="repeater-item"></div></div><div class="elementor-widget-button"></div></div> | |
(function( $ ){ | |
$(".elementor-column .dce-acf-repater-").each(function() { | |
if (!$(this).has(".repeater-item").length) { | |
hide = $(this).closest('.elementor-column').find(".elementor-widget-button").hide(); | |
} | |
}); | |
})(jQuery); |
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
//custom-query-name is set in Elementor as query ID | |
add_action( 'elementor/query/custom-query-name', function( $query ) { | |
$meta_query = (array)$query->get('meta_query'); | |
$meta_query[] = array( | |
'key' => 'custom_field', | |
'value' => '', | |
'compare' => '!=', | |
); | |
$query->set('meta_query',$meta_query); | |
} ); |
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 | |
//Handy when CPT previews are used in different templates across the site | |
add_action( 'loop_start', 'recipes_loop_start' ); | |
function recipes_loop_start( $query ){ | |
if ( !$query->is_main_query() && $query->get('post_type')== 'recipe' && !is_admin()) echo "<ul class='recipes-preview'>"; | |
} | |
add_action( 'loop_end', 'recipes_loop_end' ); | |
function recipes_loop_end( $query ){ | |
if ( !$query->is_main_query() && $query->get('post_type')== 'recipe' && !is_admin()) echo "</ul>"; |
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 | |
//Examples of input | |
$input = "http://www.example.com/cat/cat-child/slug/"; | |
$input = "http://www.example.com/cat/slug"; | |
$input = "http://www.example.com/cat/slug/"; | |
$input = "http://www.example.com/cat/slug/?dsss&efsdc=dc"; | |
//This line will always return "slug" | |
$slug = basename(strtok(str_replace(' ', '', htmlspecialchars($input )), '?')).PHP_EOL; | |
echo $slug; | |
//Useful for further use with get_term_by('slug', $slug, $tax); |
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
//Gist embeds in Gutenberg, quick fix | |
//Works if you add https://gist.github.com links as regular links | |
add_filter( 'the_content', 'gist_in_gutenberg' ); | |
function gist_in_gutenberg( $content ) { | |
$doc = new DOMDocument(); | |
$doc->loadHTML($content); | |
foreach ($doc->getElementsByTagName('a') as $link){ | |
$href = $link->getAttribute('href'); | |
if (strpos($href, 'gist.github.com') !== false) { | |
$element = $doc->createElement('script'); |
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
server { | |
listen 80; | |
listen [::]:80; | |
server_name outfunnel.com www.outfunnel.com; | |
root /var/www/outfunnel.com-production; | |
index index.php; |
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
//Let any user who can edit page insert unfiltered html in text editor | |
add_action( 'init', 'reply_unfiltered_html' ); | |
function reply_unfiltered_html() { | |
$user = wp_get_current_user(); | |
if ( current_user_can('edit_pages') ) | |
kses_remove_filters(); | |
} | |
//Let users with certain roles insert unfiltered html in text editor | |
add_action( 'init', 'reply_unfiltered_html_for_roles' ); | |
function reply_unfiltered_html_for_roles() { |
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
//Check if plugin is Network activated | |
if (!function_exists('is_plugin_active_for_network')) require_once( ABSPATH . '/wp-admin/includes/plugin.php'); | |
$plugins = get_plugins(); | |
foreach( $plugins as $plugin_file => $plugin_info ) { | |
if ( $plugin_info['TextDomain'] === $this->plugin_name ){ | |
$plugin = $plugin_file; | |
break; | |
} | |
} | |
//And set constant |