SyncCheck() ) delete_option('acf_flexcol'); if( get_option('acf_flexcol') != 'synced' ) add_filter('acf/settings/load_json', array($this, 'acf_json_load_point') ); if( get_option('acf_flexcol') != 'synced' && $this->SyncCheck() ) { update_option('acf_flexcol', 'synced'); update_option('acf_flexcol_opts', array( 'loadboots' => 1, 'hideposteditor' => 1, 'hidepageeditor' => 1 )); } //Override the_content() to display columns add_filter('the_content', array($this, 'new_the_content') ); //Bootstrap Grid CSS add_action('wp_enqueue_scripts', array($this, 'styles_and_scripts') ); //LI Column CSS add_action('wp_head', array($this, 'li_columns') ); //LI Column Editor Styles add_action( 'admin_init', array($this, 'add_editor_style') ); //LI Column Editor Scripts add_action( 'after_wp_tiny_mce', array($this, 'add_editor_scripts') ); //Carousel Image Sizes add_image_size( 'Mobile', 768, 1024 ); add_image_size( 'Tablet', 992, 1200 ); add_image_size( 'Desktop', 1280, 1080 ); add_image_size( 'Widescreen', 2000, 1280 ); else: //ALERT and DEACTIVATE - no ACF PRO add_action( 'admin_init', array($this, 'plugin_deactivate') ); add_action( 'admin_notices', array( $this, 'plugin_admin_notice') ); endif; } function plugin_deactivate(){ deactivate_plugins( plugin_basename( __FILE__ ) ); } function plugin_admin_notice(){ $url = 'https://www.advancedcustomfields.com/pro/'; echo '
'.__('ACF Flexible Columns', 'acf-flexible-columns').' '.sprintf( wp_kses( __('requires the Advanced Custom Fields Pro plugin in order to function; the plug-in has been deactivated', 'acf-flexible-columns'), array( 'a' => array( 'href' => array() ) ) ), esc_url( $url ) ).'
'.__('ACF Flexible Columns', 'acf-flexible-columns').' '. __(' is now activated. ACF Flexible Columns PRO has been deactivated to prevent conflicts.', 'acf-flexible-columns').'
'.__('Columns rely on Bootstrap 3 grid styles to function, if you already have Bootstrap 3 styles loaded in your template you can safely disable loading Bootstrap. (Note this CSS file only contains the basic grid functionality from Bootstrap, not the entire library)', 'acf-flexible-columns').'
'; } function load_aos(){ printf( '', isset( $this->options['aos'] ) ? esc_attr( 'checked="checked"') : '' ); echo '
'.__('Animations on each column block rely on the AOS Library to function. If you are already including this library in your theme you may safely disable loading these files.', 'acf-flexible-columns').'
'; } function load_slick(){ printf( '', isset( $this->options['slick'] ) ? esc_attr( 'checked="checked"') : '' ); echo '
'.__('The photo carousel relies on the Slick Library to function. If you are already including this library in your theme you may safely disable loading these files.', 'acf-flexible-columns').'
'; } function hide_post_editor(){ printf( '', isset( $this->options['hideposteditor'] ) ? esc_attr( 'checked="checked"') : '' ); echo '
'.__('The regular Post editor is replaced by the column editor, if you need it back for any reason, uncheck this box', 'acf-flexible-columns').'
'; } function hide_page_editor(){ printf( '', isset( $this->options['hidepageeditor'] ) ? esc_attr( 'checked="checked"') : '' ); echo '
'.__('The regular Page editor is replaced by the column editor, if you need it back for any reason, uncheck this box', 'acf-flexible-columns').'
'; } function enable_containers(){ printf( '', isset( $this->options['enablecontainers'] ) ? esc_attr( 'checked="checked"') : '' ); echo '
'.__('You can now add .container & .container-fluid around each row, if upgrading, add a \'container\' field above the first Column in each main Layout where 1 = .container and 0 = .container-fluid', 'acf-flexible-columns').'
'; } function disable_licol_styles(){ printf( '', isset( $this->options['disablelicolstyles'] ) ? esc_attr( 'checked="checked"') : '' ); echo '
'.__('Remove the embeded styles added to the page for the list item columns:', 'acf-flexible-columns').'
.li-col-2{-webkit-column-count:2;-moz-column-count:2;column-count:2;}.li-col-3{-webkit-column-count:3;-moz-column-count:3;column-count:3;}.li-col-4{-webkit-column-count:4;-moz-column-count:4;column-count:4;}.li-col-5{-webkit-column-count:5;-moz-column-count:5;column-count:5;}.li-col-6{-webkit-column-count:6;-moz-column-count:6;column-count:6;}';
}
function SyncCheck(){
global $wpdb;
$args = array(
'name' => 'group_574881bf6b7db',
'post_type' => 'acf-field-group',
'post_status' => 'publish',
'numberposts' => 1
);
$synced = get_posts($args);
if( $synced ) return true;
else return false;
}
function noeditor(){
$opts = get_option('acf_flexcol_opts');
if( isset($opts['hideposteditor']) && $opts['hideposteditor'] == true) remove_post_type_support('post', 'editor');
if( isset($opts['hidepageeditor']) && $opts['hidepageeditor'] == true ) remove_post_type_support('page', 'editor');
}
function acf_json_load_point( $paths ){
$paths[] = plugin_dir_path(__FILE__).'acf-json/';
return $paths;
}
function styles_and_scripts(){
//CSS Styles
$opts = get_option('acf_flexcol_opts');
if( $opts['bootstrap'] ) wp_enqueue_style( 'BootstrapGrids', plugins_url('css/bootstrap.grids.min.css', __FILE__), 'all' );
if( $opts['aos'] ) wp_enqueue_style( 'AOS', plugins_url('css/aos.min.css', __FILE__), 'all' );
if( $opts['slick'] ) wp_enqueue_style( 'Slick', plugins_url('css/slick.css', __FILE__), 'all' );
if( $opts['slick'] ) wp_enqueue_style( 'Slick-Theme', plugins_url('css/slick-theme.css', __FILE__), 'all' );
//JS Scripts
if( $opts['aos'] ) wp_enqueue_script( 'AOS', plugins_url('js/aos.min.js', __FILE__), array('jquery') );
if( $opts['slick'] ) wp_enqueue_script( 'Slick', plugins_url('js/slick.min.js', __FILE__), array('jquery') );
}
function li_columns(){
$opts = get_option('acf_flexcol_opts');
if( !$opts['bootstrap'] && !$opts['disablelicolstyles'] ){
?>
', plugins_url('/js/tinymce-licols.js', __FILE__) );
}
function add_editor_style(){
add_editor_style(plugins_url('css/editor-li-style.css', __FILE__) );
}
function new_the_content($content){
global $post;
$opts = get_option('acf_flexcol_opts');
$content = '';
if( have_rows('rows') ):
while( have_rows('rows') ):
the_row();
$content .= apply_filters( 'flexible_columns_wrap_outer', false );
if( isset($opts['enablecontainers']) && $opts['enablecontainers'] == true):
$container = get_sub_field('container');
$nocontainer = get_sub_field('full_width_row');
if( $nocontainer ){ $container = false; }
if( $container == 1 ) $content .= '