Skip to content

Instantly share code, notes, and snippets.

@Fobiya
Last active January 23, 2020 10:10
Show Gist options
  • Save Fobiya/ad3416b681f86c9eaf1da77c2b23662b to your computer and use it in GitHub Desktop.
Save Fobiya/ad3416b681f86c9eaf1da77c2b23662b to your computer and use it in GitHub Desktop.
acf plagin
/----------------------------------------------------------- acf filter in function php ---------------------------------------------------------------------/
add_shortcode('brand', 'brand_config');
// END BRAND LINKS
//add_filter( 'tradersoft', 'do_shortcode');
add_filter( 'wpcf7_form_elements', 'do_shortcode');
add_filter('acf/format_value/type=wysiwyg', 'do_shortcode');
add_filter('acf/format_value/type=textarea', 'do_shortcode');
add_filter('acf/format_value/type=text', 'do_shortcode');
add_filter('acf/format_value/type=email', 'do_shortcode');
add_filter('acf/format_value/type=url', 'do_shortcode');
add_filter('acf/format_value/type=number', 'do_shortcode');
add_filter('acf/format_value/type=image', 'do_shortcode');
add_filter('acf/format_value/type=link', 'do_shortcode');
/----------------------------------------------------------- acf filter in function php ---------------------------------------------------------------------/
/----------------------------------------------------------- wpml_active_languages ---------------------------------------------------------------------/
if ( function_exists( 'acf_add_options_page' ) ) {
// Main Theme Settings Page
$parent = acf_add_options_page( array(
'page_title' => 'Footer',
'menu_title' => 'Footer',
'redirect' => 'Footer',
) );
// Language Specific Options
// Translatable options specific languages. e.g., social profiles links
$la = apply_filters( 'wpml_active_languages', NULL,);
$languages = array_keys($la);
foreach ( $languages as $lang ) {
acf_add_options_sub_page( array(
'page_title' => 'Footer (' . strtoupper($la[$lang]['native_name']) . ')',
'menu_title' => __('Footer (' . strtoupper($la[$lang]['native_name']) . ')', 'text-domain'),
'menu_slug' => "options-${lang}",
'post_id' => $lang,
'parent' => $parent['menu_slug']
) );
}
}
/----------------------------------------------------------- wpml_active_languages ---------------------------------------------------------------------/
/----------------------------------------------------------- wpml_active_languages ---------------------------------------------------------------------/
$my_current_lang = apply_filters( 'wpml_current_language', NULL );
echo $my_current_lang; active
$languages = apply_filters( 'wpml_active_languages', NULL );
var_dump(array_keys($languages));
/----------------------------------------------------------- wpml_active_languages ---------------------------------------------------------------------/
/----------------------------------------------------------- acf echo ECHO LABLE FOR ADMIN PANEL ---------------------------------------------------------------------/
<?php $select = get_field_object('field_5dc948108dc64');
print_r($select[sub_fields][0][label]);
foreach( $select[sub_fields] as $value => $label ): ?>
<li><?php echo $label[name]; ?></li>
<?php endforeach; ?>
$select = get_sub_field_object('spreads_indicative');
print_r($select['_name']);
/----------------------------------------------------------- end acf echo ECHO LABLE FOR ADMIN PANEL ---------------------------------------------------------------------/
/----------------------------------------------------------- echo language ---------------------------------------------------------------------/
$lang = get_bloginfo("language"); ?> (<?php
if( $lang
echo en-US
/----------------------------------------------------------- end echo language ---------------------------------------------------------------------/
------------small remember
<?php echo get_row_index(); ?> //namber
<?php the_post_thumbnail_url ("back") ?> BACKRAUND WP
------------small remember
/----------------------------------------------------------- global options ---------------------------------------------------------------------/
theme (child theme) functions.php file
$reg_link = get_permalink(get_global_option('registration_page'));
/**
* Advanced Custom Fields Options function
* Always fetch an Options field value from the default language
*/
function cl_acf_set_language() {
return acf_get_setting('default_language');
}
function get_global_option($name) {
add_filter('acf/settings/current_language', 'cl_acf_set_language', 100);
$option = get_field($name, 'option');
remove_filter('acf/settings/current_language', 'cl_acf_set_language', 100);
return $option;
}
https://support.advancedcustomfields.com/forums/topic/wpml-acf-5-0-9-and-options-page/
<?php
$visa_mastercard = get_global_option('accept', 'options');
?>
<img class="first" src="<?php echo $visa_mastercard['url'];?>" alt="">
<?php
// Set language to default
add_filter('acf/settings/current_language', 'cl_acf_set_language', 100);
if (have_rows('fotter_social_network', 'option')) : ?>
<div class="col-lg-12">
<ul class='social-networks'>
<?php while (have_rows('fotter_social_network', 'option')) : the_row(); ?>
<?php if (get_row_layout() == 'facebook_1') : ?>
<li>
<a target="_blank" class="facebook-footer" href="<?php the_sub_field('facebook'); ?>">
<i class='ion-social-facebook'></i>
</a>
</li>
<?php endif; ?>
<?php if (get_row_layout() == 'youtube_1') : ?>
<li>
<a target="_blank" class="youtube" href="<?php the_sub_field('youtube'); ?>">
<i class='ion-social-youtube'></i>
</a>
</li>
<?php endif; ?>
<?php if (get_row_layout() == 'twitter_1') : ?>
<li>
<a target="_blank" class="twitter" href="<?php the_sub_field('twitter'); ?>">
<i class='ion-social-twitter'></i>
</a>
</li>
<?php endif; ?>
<?php if (get_row_layout() == 'instagram_1') : ?>
<li>
<a target="_blank" class="instagram" href="<?php the_sub_field('instagram'); ?>">
<i class='ion-social-instagram-outline'></i>
</a>
</li>
<?php endif; ?>
<?php if (get_row_layout() == 'linkedin_1') : ?>
<li>
<a target="_blank" class="linkedin" href="<?php the_sub_field('linkedin'); ?>">
<i class='ion-social-linkedin'></i>
</a>
</li>
<?php endif; ?>
<?php endwhile; ?>
</ul>
</div>
<?php endif;
// Set language to current
remove_filter('acf/settings/current_language', 'cl_acf_set_language', 100);
?>
/----------------------------------------------------------- global options END ---------------------------------------------------------------------/
/----------------------------------------------------------- Flexible Content ---------------------------------------------------------------------/
<?php if( have_rows('withdrawal__methods__5__box__diamond_copy') ): ?> <!-- Flexible Content withdrawal__methods__5__box__diamond_copy -->
<?php while ( have_rows('withdrawal__methods__5__box__diamond_copy') ) : the_row(); ?> <!-- Flexible Content withdrawal__methods__5__box__diamond_copy -->
<?php if( get_row_layout() == 'new__diamond' ): ?> <!-- new__diamond -->
<div class="table-block col-12 col-md-4">
<div class="table-head"><?php the_sub_field('withdrawal__methods__5__diamond__title'); ?></div>
<?php if( have_rows('withdrawal__methods__5__diamond__list__content') ): ?> <!-- Repeater withdrawal__methods__5__diamond__list__content -->
<div class="table-cell-content">
<?php while( have_rows('withdrawal__methods__5__diamond__list__content') ): the_row(); ?> <!-- Repeater withdrawal__methods__5__diamond__list__content -->
<p class="text-center"><?php the_sub_field('withdrawal__methods__5__diamond__list__paragraph'); ?></p>
<?php endwhile; ?> <!-- END Repeater withdrawal__methods__5__diamond__list__content -->
</div>
<?php endif; ?> <!-- END Repeater withdrawal__methods__5__diamond__list__content -->
</div>
<?php endif; ?> <!-- new__diamond -->
<?php endwhile; ?> <!-- End Flexible Content withdrawal__methods__5__box__diamond_copy -->
<?php endif; ?> <!-- End Flexible Content withdrawal__methods__5__box__diamond_copy -->
+ replicator + Flexible
/----------------------------------------------------------- END Flexible Content ---------------------------------------------------------------------/
/--------------------------------------------------------------------------------------------------------------------------------/
<?php if( have_rows('box__withdrawal__methods') ): ?> <!-- Flexible Content box__withdrawal__methods -->
<?php while ( have_rows('box__withdrawal__methods') ) : the_row(); ?> <!-- Flexible Content box__withdrawal__methods -->
<?php if( get_row_layout() == 'paragraph' ): ?>
the_sub_field('text');
<?php endif; ?>
<?php endwhile; ?> <!-- End Flexible Content box__withdrawal__methods -->
<?php endif; ?> <!-- End Flexible Content box__withdrawal__methods -->
/--------------------------------------------------------------------------------------------------------------------------------/
/--------------------------------------------------------------------------------------------------------------------------------/
<?php if( have_rows('home__text__content__right') ): ?> <!-- Flexible home__text__content__right -->
<?php while( have_rows('home__text__content__right') ): the_row();
// vars
$home__curl__right__link = get_sub_field('home__curl__right__link'); ?> <!-- Flexible home__text__content__right -->
<?php endwhile; ?> <!-- END Flexible home__text__content__right -->
<?php endif; ?> <!-- END Flexible home__text__content__right -->
/--------------------------------------------------------------------------------------------------------------------------------/
<?php if( have_rows('repeater_field_name') ): ?> <!-- Repeater repeater_field_name -->
<?php while( have_rows('repeater_field_name') ): the_row();
// vars
$image = get_sub_field('image'); ?> <!-- Repeater repeater_field_name -->
<?php endwhile; ?> <!-- END Repeater repeater_field_name -->
<?php endif; ?> <!-- END Repeater repeater_field_name -->
/--------------------------------------------------------------------------------------------------------------------------------/
<?php if( $under__the): ?><!-- Repeater repeater_field_name --> <!-- if under__the -->
<p class="paragraf">
<?php echo $under__the; ?>
</p>
<?php endif; ?> <!--END if under__the -->
/-------------------------------- регистрация опциий вывода ------------------------------------------------------------------------------------------------/
if( function_exists('acf_add_options_page') ) {
$option_page = acf_add_options_page(array(
'page_title' => 'Footer settings',
'menu_title' => 'Footer settings',
'menu_slug' => 'footer',
'capability' => 'edit_posts',
'redirect' => false
));
}
/--------------------------------- select ---------------------------------/
<?php if( get_field('add_css', 'options')): ?>
<style type="text/css">
<?php the_field('yours_css', 'options'); ?>
</style>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment