Functions file containing code for adding acf settings options to WP admin menu. See lines #244 - #266
<?php
// LOAD BONES CORE (if you remove this, the theme will break)
require_once( 'library/bones.php' );
// MAINTENANCE MODE CUSTOM SETTING
require_once( 'library/maintenance.php' );
// Privacy Policy Shortcode
function privacy_policy() {
$file = "http://www.company.com/privacy/privacy.txt";
$data = file_get_contents($file);
return $data;
}
add_shortcode( 'privacy', 'privacy_policy' );
// Pull Quote Shortcode
function pullquote_func($atts, $content = null ) {
return '<span class="pullquote">' . do_shortcode($content) . '</span>';
}
add_shortcode( 'pullquote', 'pullquote_func' );
/*********************
CTA SHORTCODE
*********************/
function cta_func(){
return '<div class="cta"><h2 class="cta-headline">' . get_field( 'cta_headline' ) . '</h2><p>' . get_field( 'cta_text' ) . '</p><a class="button" href="' . get_field( 'cta_button_link' ) . '">' . get_field( 'cta_button_text' ) . '</a></div>';
}
add_shortcode( 'cta', 'cta_func' );
// TGM Plugin
require_once( 'class-tgm-plugin-activation.php');
add_action( 'tgmpa_register', 'yourtag_online_register_required_plugins' );
function yourtag_online_register_required_plugins() {
/*
* Array of plugin arrays. Required keys are name and slug.
* If the source is NOT from the .org repo, then source is also required.
*/
$plugins = array(
// This is an example of how to include a plugin bundled with a theme.
array(
'name' => 'Advanced Custom Fields Pro', // The plugin name.
'slug' => 'advanced-custom-fields-pro', // The plugin slug (typically the folder name).
'source' => get_template_directory() . '/library/plugins/advanced-custom-fields-pro.zip', // The plugin source.
'required' => true, // If false, the plugin is only 'recommended' instead of required.
'force_activation' => true, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch.
'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins.
),
array(
'name' => 'Wp Migrate DB Pro', // The plugin name.
'slug' => 'wp-migrate-db-pro', // The plugin slug (typically the folder name).
'source' => get_template_directory() . '/library/plugins/wp-migrate-db-pro.zip', // The plugin source.
'required' => true, // If false, the plugin is only 'recommended' instead of required.
'force_activation' => true, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch.
'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins.
),
array(
'name' => 'Wp Migrate DB Pro Media Files', // The plugin name.
'slug' => 'wp-migrate-db-pro-media-files', // The plugin slug (typically the folder name).
'source' => get_template_directory() . '/library/plugins/wp-migrate-db-pro-media-files.zip', // The plugin source.
'required' => true, // If false, the plugin is only 'recommended' instead of required.
'force_activation' => true, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch.
'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins.
),
// This is an example of how to include a plugin from an arbitrary external source in your theme.
array(
'name' => 'Title and Nofollow For Links', // The plugin name.
'slug' => 'title-and-nofollow-for-links', // The plugin slug (typically the folder name).
'required' => true, // If false, the plugin is only 'recommended' instead of required.
),
array(
'name' => 'RICG Responsive Images',
'slug' => 'ricg-responsive-images',
'required' => true,
),
array(
'name' => 'WordPress SEO by Yoast',
'slug' => 'wordpress-seo',
'required' => true,
),
array(
'name' => 'Redirection',
'slug' => 'redirection',
'required' => true,
),
array(
'name' => 'Duplicate Post',
'slug' => 'duplicate-post',
'required' => true,
),
);
$config = array(
'id' => 'yourtagname-online', // Unique ID for hashing notices for multiple instances of TGMPA.
'default_path' => '', // Default absolute path to bundled plugins.
'menu' => 'tgmpa-install-plugins', // Menu slug.
'parent_slug' => 'themes.php', // Parent menu slug.
'capability' => 'edit_theme_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used.
'has_notices' => true, // Show admin notices or not.
'dismissable' => true, // If false, a user cannot dismiss the nag message.
'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
'is_automatic' => false, // Automatically activate plugins after installation or not.
'message' => '', // Message to output right before the plugins table.
);
tgmpa( $plugins, $config );
}
// Social Sharing
function social_sharing_buttons($content) {
if(is_single()){
// Get current page URL
$socialURL = urlencode(get_permalink());
// Get current page title
$socialTitle = str_replace( ' ', '%20', get_the_title());
// Construct sharing URL without using any script
$twitterURL = 'https://twitter.com/intent/tweet?text='.$socialTitle.'&url='.$socialURL.'&via=yourtwitter';
$facebookURL = 'https://www.facebook.com/sharer/sharer.php?u='.$socialURL;
$linkedInURL = 'https://www.linkedin.com/shareArticle?mini=true&url='.$socialURL.'&title='.$socialTitle;
// Add sharing button at the end of page/page content
$variable .= '<div class="social-sharing">';
$variable .= '<span class="social-sharing-label">Share on</span>';
$variable .= '<a class="social-link social-twitter" href="'. $twitterURL .'" target="_blank"><span class="social-link-icon"><svg viewBox="0 0 512 512" preserveAspectRatio="xMidYMid meet"><path d="M419.6 168.6c-11.7 5.2-24.2 8.7-37.4 10.2 13.4-8.1 23.8-20.8 28.6-36 -12.6 7.5-26.5 12.9-41.3 15.8 -11.9-12.6-28.8-20.6-47.5-20.6 -42 0-72.9 39.2-63.4 79.9 -54.1-2.7-102.1-28.6-134.2-68 -17 29.2-8.8 67.5 20.1 86.9 -10.7-0.3-20.7-3.3-29.5-8.1 -0.7 30.2 20.9 58.4 52.2 64.6 -9.2 2.5-19.2 3.1-29.4 1.1 8.3 25.9 32.3 44.7 60.8 45.2 -27.4 21.4-61.8 31-96.4 27 28.8 18.5 63 29.2 99.8 29.2 120.8 0 189.1-102.1 185-193.6C399.9 193.1 410.9 181.7 419.6 168.6z"></path></svg></span><span class="social-link-label">Twitter</span></a>';
$variable .= '<a class="social-link social-facebook" href="'.$facebookURL.'" target="_blank"><span class="social-link-icon"><svg viewBox="0 0 512 512" preserveAspectRatio="xMidYMid meet"><path d="M211.9 197.4h-36.7v59.9h36.7V433.1h70.5V256.5h49.2l5.2-59.1h-54.4c0 0 0-22.1 0-33.7 0-13.9 2.8-19.5 16.3-19.5 10.9 0 38.2 0 38.2 0V82.9c0 0-40.2 0-48.8 0 -52.5 0-76.1 23.1-76.1 67.3C211.9 188.8 211.9 197.4 211.9 197.4z"></path></svg></span><span class="social-link-label">Facebook</span></a>';
$variable .= '<a class="social-link social-linkedin" href="'.$linkedInURL.'" target="_blank"><span class="social-link-icon"><svg viewBox="0 0 512 512" preserveAspectRatio="xMidYMid meet"><path d="M186.4 142.4c0 19-15.3 34.5-34.2 34.5 -18.9 0-34.2-15.4-34.2-34.5 0-19 15.3-34.5 34.2-34.5C171.1 107.9 186.4 123.4 186.4 142.4zM181.4 201.3h-57.8V388.1h57.8V201.3zM273.8 201.3h-55.4V388.1h55.4c0 0 0-69.3 0-98 0-26.3 12.1-41.9 35.2-41.9 21.3 0 31.5 15 31.5 41.9 0 26.9 0 98 0 98h57.5c0 0 0-68.2 0-118.3 0-50-28.3-74.2-68-74.2 -39.6 0-56.3 30.9-56.3 30.9v-25.2H273.8z"></path></svg></span><span class="social-link-label">LinkedIn</span></a>';
$variable .= '</div>';
return $variable.$content;
}else{
// if not a post/page then don't include sharing button
return $variable.$content;
}
};
add_filter( 'the_content', 'social_sharing_buttons');
/*********************
LAUNCH BONES
Let's get everything up and running.
*********************/
function bones_ahoy() {
// Programs Custom Post Type
require_once( 'library/customposttypes.php' );
// launching operation cleanup
add_action( 'init', 'bones_head_cleanup' );
// A better title
add_filter( 'wp_title', 'rw_title', 10, 3 );
// remove WP version from RSS
add_filter( 'the_generator', 'bones_rss_version' );
// remove pesky injected css for recent comments widget
add_filter( 'wp_head', 'bones_remove_wp_widget_recent_comments_style', 1 );
// clean up comment styles in the head
add_action( 'wp_head', 'bones_remove_recent_comments_style', 1 );
// clean up gallery output in wp
add_filter( 'gallery_style', 'bones_gallery_style' );
// enqueue base scripts and styles
add_action( 'wp_enqueue_scripts', 'bones_scripts_and_styles', 999 );
// ie conditional wrapper
// launching this stuff after theme setup
bones_theme_support();
// adding sidebars to Wordpress (these are created in functions.php)
add_action( 'widgets_init', 'bones_register_sidebars' );
// cleaning up random code around images
add_filter( 'the_content', 'bones_filter_ptags_on_images' );
// cleaning up excerpt
add_filter( 'excerpt_more', 'bones_excerpt_more' );
} /* end bones ahoy */
// let's get this party started
add_action( 'after_setup_theme', 'bones_ahoy' );
/************* OEMBED SIZE OPTIONS *************/
if ( ! isset( $content_width ) ) {
$content_width = 680;
}
/************* ACTIVE SIDEBARS ********************/
// Sidebars & Widgetizes Areas
function bones_register_sidebars() {
register_sidebar(array(
'id' => 'sidebar1',
'name' => __( 'Sidebar 1' ),
'description' => __( 'The first (primary) sidebar.' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widgettitle">',
'after_title' => '</h4>',
));
register_sidebar(array(
'id' => 'sidebar_blog',
'name' => __( 'Sidebar Blog' ),
'description' => __( 'The first (primary) sidebar.' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widgettitle">',
'after_title' => '</h4>',
));
} // don't remove this bracket!
/*
Fix for jQuery conflict
*/
function enqueue_scripts() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js', false, false, false );
wp_enqueue_script( 'jquery' );
}
add_action('wp_enqueue_scripts', 'enqueue_scripts');
/*
Add Theme Options for ACF
*/
if( function_exists('acf_add_options_page') ) {
acf_add_options_page(array(
'page_title' => 'Theme General Settings',
'menu_title' => 'Theme Settings',
'menu_slug' => 'theme-general-settings',
'capability' => 'edit_posts',
'redirect' => false
));
acf_add_options_sub_page(array(
'page_title' => 'Theme Header Settings',
'menu_title' => 'Header',
'parent_slug' => 'theme-general-settings',
));
acf_add_options_sub_page(array(
'page_title' => 'Theme Footer Settings',
'menu_title' => 'Footer',
'parent_slug' => 'theme-general-settings',
));
}
/*
Allow SVG uploads
*/
function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
/* DON'T DELETE THIS CLOSING TAG */ ?>