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_footer', 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 ) ).'
';
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(
' Bootstrap Grids ',
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(
' AOS (Animated On Scroll) Library CSS & JS ',
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(
' Slick Library CSS & JS ',
isset( $this->options['slick'] ) ? 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 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 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'] ){
?>
', 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;
$content = '';
if( have_rows('rows') ):
while( have_rows('rows') ):
the_row();
$content .= apply_filters( 'flexible_columns_wrap_outer', false );
$nocontainer = get_sub_field('full_width_row');
if( !$nocontainer ) $content .= '
'; else $content .= '
';
$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 );
$content .= '
'; //End .container/container-fluid
$content .= apply_filters( 'flexible_columns_wrap_outer_end', false );
endwhile; //end rows
endif;
return apply_filters( 'flexible_columns_content', $content );
}
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-xs-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);
$type = strtolower($animate[0]['type']);
$animate_data = false;
if( $type ):
$dir = strtolower($animate[0][$type.'_direction']);
$dur = $animate[0]['duration']*1000;
$delay = $animate[0]['delay']*1000;
$animate_data = ' data-aos="'.$type.'-'.$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('/