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_action_links( $links ){ $dl = plugin_dir_url( __FILE__ ).'acf-json/acf-flexible-columns.json'; $links = array_merge( array( 'JSON Import File'), $links); return $links; } 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 ) ).'

'; if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] ); } function plugin_deactivate2(){ $oldplugin = 'acf-flexible-columns-pro/acf-flexible-columns-pro.php'; deactivate_plugins( $oldplugin ); } function plugin_admin_notice2(){ echo '

'.__('ACF Flexible Columns', 'acf-flexible-columns').' '. __(' is now activated. ACF Flexible Columns PRO has been deactivated to prevent conflicts.', 'acf-flexible-columns').'

'; if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] ); } function migrate_thecontent(){ global $wpdb; if (isset($_GET['acffc_nonce']) && wp_verify_nonce($_GET['acffc_nonce'], 'migrate_content')): $args = array( 'post_type' => array( 'post', 'page') ); $query = new WP_Query( $args ); if( $query->have_posts() ): while( $query->have_posts() ): $query->the_post(); $oldContent = get_the_content(); $field_key = "field_574881bf81a25"; update_post_meta($query->post->ID, '_rows', $field_key ); update_post_meta($query->post->ID, 'rows', array ('full_width_row') ); update_post_meta($query->post->ID, '_rows_0_column', 'field_574881bf9302c' ); update_post_meta($query->post->ID, 'rows_0_column', array('content') ); update_post_meta($query->post->ID, '_rows_0_column_0_list_layout', 'field_574881bf9dd99' ); update_post_meta($query->post->ID, 'rows_0_column_0_list_layout', 1 ); update_post_meta($query->post->ID, '_rows_0_column_0_content', 'field_574881bf9dd23' ); update_post_meta($query->post->ID, 'rows_0_column_0_content', $oldContent ); endwhile; endif; wp_reset_postdata(); endif; } function add_plugin_page(){ add_options_page( //'edit.php?post_type=acf-field-group', 'ACF Flexible Columns', 'Flexible Columns', 'manage_options', 'acf-flexible-columns', array( $this, 'create_admin_page' ) ); } function create_admin_page(){ $this->options = get_option( 'acf_flexcol_opts' ); ?>

ACF Flexible Columns Settings

Migrate to Column System
This will copy over your previous page content into the new column content system

'; } function load_bootstrap(){ printf( '', isset( $this->options['bootstrap'] ) ? esc_attr( 'checked="checked"') : '' ); echo '

'.__('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 .= '

'; else $content .= '
'; endif; $content .= apply_filters( 'flexible_columns_wrap_inner', false ); $rowclass = array('row'); $rowclass = apply_filters('flexible_columns_row_class', $rowclass); $rowclasses = implode(' ', $rowclass); if( get_row_layout() == 'full_width_row' ): $content .= apply_filters( 'flexible_column_pre', false ); //SINGLE COLUMN if( have_rows('column') ): while( have_rows('column') ): the_row(); $content .= '
'; $content .= apply_filters( 'flexible_columns_row_prepend', false ); if( get_row_layout() ) $content .= $this->flexible_layout(get_row_layout()); $content .= apply_filters( 'flexible_columns_row_append', false ); $content .= '
'; endwhile; endif; $content .= apply_filters( 'flexible_column_post', false ); elseif( get_row_layout() == '2_column_row' ): $content .= apply_filters( 'flexible_column_pre', false ); //TWO COLUMNS - COL #1 if( have_rows('column_1') ): while( have_rows('column_1') ): the_row(); $content .= '
'; $content .= apply_filters( 'flexible_columns_row_prepend', false ); if( get_row_layout() ) $content .= $this->flexible_layout(get_row_layout()); endwhile; endif; //TWO COLUMNS - COL #2 if( have_rows('column_2') ): while( have_rows('column_2') ): the_row(); if( get_row_layout() ) $content .= $this->flexible_layout(get_row_layout()); $content .= apply_filters( 'flexible_columns_row_append', false ); $content .= '
'; endwhile; endif; $content .= apply_filters( 'flexible_column_post', false ); elseif( get_row_layout() == '3_column_row' ): $content .= apply_filters( 'flexible_column_pre', false ); //THREE COLUMNS - COL #1 if( have_rows('column_1') ): while( have_rows('column_1') ): the_row(); $content .= '
'; $content .= apply_filters( 'flexible_columns_row_prepend', false ); if( get_row_layout() )$content .= $this->flexible_layout(get_row_layout()); endwhile; endif; //THREE COLUMNS - COL #2 if( have_rows('column_2') ): while( have_rows('column_2') ): the_row(); if( get_row_layout() ) $content .= $this->flexible_layout(get_row_layout()); endwhile; endif; //THREE COLUMNS - COL #3 if( have_rows('column_3') ): while( have_rows('column_3') ): the_row(); if( get_row_layout() ) $content .= $this->flexible_layout(get_row_layout()); $content .= apply_filters( 'flexible_columns_row_append', false ); $content .= '
'; endwhile; endif; $content .= apply_filters( 'flexible_column_post', false ); elseif( get_row_layout() == '4_column_row' ): $content .= apply_filters( 'flexible_column_pre', false ); //FOUR COLUMNS - COL #1 if( have_rows('column_1') ): while( have_rows('column_1') ): the_row(); $content .= '
'; $content .= apply_filters( 'flexible_columns_row_prepend', false ); if( get_row_layout() ) $content .= $this->flexible_layout(get_row_layout()); endwhile; endif; //FOUR COLUMNS - COL #2 if( have_rows('column_2') ): while( have_rows('column_2') ): the_row(); if( get_row_layout() ) $content .= $this->flexible_layout(get_row_layout()); endwhile; endif; //FOUR COLUMNS - COL #3 if( have_rows('column_3') ): while( have_rows('column_3') ): the_row(); if( get_row_layout() ) $content .= $this->flexible_layout(get_row_layout()); endwhile; endif; //FOUR COLUMNS - COL #4 if( have_rows('column_4') ): while( have_rows('column_4') ): the_row(); if( get_row_layout() ) $content .= $this->flexible_layout(get_row_layout()); $content .= apply_filters( 'flexible_columns_row_append', false ); $content .= '
'; endwhile; endif; $content .= apply_filters( 'flexible_columns_post', false ); endif; $content .= apply_filters( 'flexible_columns_wrap_inner_end', false ); if( isset($opts['enablecontainers']) && $opts['enablecontainers'] == true) $content .= '
'; //End .container/container-fluid $content .= apply_filters( 'flexible_columns_wrap_outer_end', false ); endwhile; //end rows endif; if ( !post_password_required() ) { return apply_filters( 'flexible_columns_content', $content ); }else{ return get_the_password_form(); } } function flexible_layout($type){ switch($type): #CONTENT case 'content': //$image = get_sub_field('image'); $content = get_sub_field('content'); $md = ''; $sm = ''; $xs = ''; $width = get_sub_field('width'); if( !$width ): $col = 'col-sm-12'; else: $mdw = $width[0]['desktop']; $smw = $width[0]['tablet']; $xsw = $width[0]['mobile']; $xs = ' col-xs-'.$xsw; if( $smw != $xsw ) $sm = ' col-sm-'.$smw; if( (!$sm && $mdw != $xsw) || ($sm && $mdw != $smw) ) $md = ' col-md-'.$mdw; $col = ltrim($md.$sm.$xs); endif; $animate = get_sub_field('animate'); // print_r($animate); $atype = strtolower($animate[0]['type']); $animate_data = false; if( $atype ): $dir = strtolower($animate[0][$atype.'_direction']); $dur = $animate[0]['duration']*1000; $delay = $animate[0]['delay']*1000; $animate_data = ' data-aos="'.$atype.'-'.$dir.'" data-aos-duration="'.$dur.'" data-aos-delay="'.$delay.'" '; endif; $licols = get_sub_field('list_layout'); $listyle = false; if( $licols != 1){ $listyle = 'li-col-'.$licols; } //if( $listyle ) $content = str_replace($lifind, $lirep, $content); if( $listyle ) $content = preg_replace('/<([uo]l)(\\sclass="([a-z0-9.])*'.$listyle.'([a-z0-9.])*")*>/m', '<$1 class="$3'.$listyle.'$4">', $content); //if ( $image ) $columndata .= '
' . do_shortcode($content) .'
'; //else $colclasses = explode(" ", $col); $colclasses = apply_filters('flexible_columns_col_class', $colclasses, get_row(true)); $colclasses = implode(' ', $colclasses); $columndata .= '
' . do_shortcode($content) .'
'; break; case 'image_carousel': $carousel = get_sub_field('carousel'); $settings = get_sub_field('carousel_settings'); $autoplay = $settings[0]['autoplay']*1000; $arrows = $settings[0]['show_arrows']; $dots = $settings[0]['show_dots']; $fade = $settings[0]['enable_fade']; $ratio = $settings[0]['aspect_ratio']; $data = array(); if( $autoplay ) $data[] = '"autoplay" : true, "autoplaySpeed" : '.$autoplay; if( $arrows ) $data[] = '"arrows" : true'; else $data[] = '"arrows" : false'; if( $dots ) $data[] = '"dots" : true'; else $data[] = '"dots" : false'; if( $fade ) $data[] = '"fade" : true'; else $data[] = '"fade" : false'; $data = implode(', ', $data); $columndata .= ''; break; default: $columndata .= apply_filters('flexible_layout', $type); endswitch; return $columndata; } } $idp_acf_flexcols = new IDP_ACF_FlexCols();