'3703',
'slug' => 'acf-blocks',
'type' => 'plugin',
'public_key' => 'pk_5e62b729dd843294873241dcc6402',
'is_premium' => false,
'has_addons' => false,
'has_paid_plans' => false,
'menu' => array(
'first-path' => 'plugins.php',
'account' => false,
'support' => false,
),
) );
}
return $acfb_fs;
}
// Init Freemius.
acfb_fs();
// Signal that SDK was initiated.
do_action( 'acfb_fs_loaded' );
}
// Add Custom Blocks Panel in Gutenberg
function acfb_block_categories( $categories, $post ) {
return array_merge(
$categories,
array(
array(
'slug' => 'acfb-blocks',
'title' => __( 'ACF Blocks', 'acfblocks-master' ),
),
)
);
}
add_filter( 'block_categories', 'acfb_block_categories', 10, 2 );
// Register Blocks
add_action('acf/init', 'acfb_blocks');
function acfb_blocks() {
// check function exists.
if( function_exists('acf_register_block_type') ) {
// register a testimonial block.
acf_register_block_type(array(
'name' => 'acfb-testimonial',
'mode' => 'preview',
'title' => __('Testimonial'),
'description' => __('Let others know what your clients or customers say about you.'),
'render_template' => plugin_dir_path( __FILE__ ) . 'block-templates/testimonial.php',
'category' => 'acfb-blocks',
'icon' => '',
'enqueue_assets' => function(){
wp_enqueue_style( 'acfb-blocks-css', plugin_dir_url( __FILE__ ) . 'css/acfblocks.css' );
},
));
// register a team block.
acf_register_block_type(array(
'name' => 'acfb-team',
'mode' => 'preview',
'title' => __('Team'),
'description' => __('Introduce your team to your site visitors in style.'),
'render_template' => plugin_dir_path( __FILE__ ) . 'block-templates/team.php',
'category' => 'acfb-blocks',
'icon' => '',
'enqueue_assets' => function(){
wp_enqueue_style( 'acfb-blocks-css', plugin_dir_url( __FILE__ ) . 'css/acfblocks.css' );
},
));
// register a multi buttons block.
acf_register_block_type(array(
'name' => 'acfb-multibuttons',
'mode' => 'preview',
'title' => __('Multi Buttons'),
'description' => __('Display multiple buttons inline with ease.'),
'render_template' => plugin_dir_path( __FILE__ ) . 'block-templates/multi-buttons.php',
'category' => 'acfb-blocks',
'icon' => '',
'enqueue_assets' => function(){
wp_enqueue_style( 'acfb-blocks-css', plugin_dir_url( __FILE__ ) . 'css/acfblocks.css' );
},
));
// register a pricing box block.
acf_register_block_type(array(
'name' => 'acfb-pricingbox',
'mode' => 'preview',
'title' => __('Pricing Box'),
'description' => __('Display your plans and offers in style.'),
'render_template' => plugin_dir_path( __FILE__ ) . 'block-templates/pricing-box.php',
'category' => 'acfb-blocks',
'icon' => '',
'enqueue_assets' => function(){
wp_enqueue_style( 'acfb-blocks-css', plugin_dir_url( __FILE__ ) . 'css/acfblocks.css' );
},
));
// register a Star Rating block.
acf_register_block_type(array(
'name' => 'acfb-starrating',
'mode' => 'preview',
'title' => __('Star Rating'),
'description' => __('Add start ratings anywhere easily.'),
'render_template' => plugin_dir_path( __FILE__ ) . 'block-templates/star-rating.php',
'category' => 'acfb-blocks',
'icon' => '',
'enqueue_assets' => function(){
wp_enqueue_style( 'acfb-blocks-css', plugin_dir_url( __FILE__ ) . 'css/acfblocks.css' );
},
));
// register a Progress Bar block.
acf_register_block_type(array(
'name' => 'acfb-progressbar',
'mode' => 'preview',
'title' => __('Progress Bar'),
'description' => __('Show your progress using percentage defined progress bars.'),
'render_template' => plugin_dir_path( __FILE__ ) . 'block-templates/progress-bar.php',
'category' => 'acfb-blocks',
'icon' => '',
'enqueue_assets' => function(){
wp_enqueue_style( 'acfb-blocks-css', plugin_dir_url( __FILE__ ) . 'css/acfblocks.css' );
},
));
// register a Counter Number block.
acf_register_block_type(array(
'name' => 'acfb-counternumber',
'mode' => 'preview',
'title' => __('Counter Number'),
'description' => __('Display stats with animated counter numbers.'),
'render_template' => plugin_dir_path( __FILE__ ) . 'block-templates/counter-number.php',
'category' => 'acfb-blocks',
'icon' => '',
'enqueue_assets' => function(){
wp_enqueue_style( 'acfb-blocks-css', plugin_dir_url( __FILE__ ) . 'css/acfblocks.css' );
wp_enqueue_script( 'acfb-blocks-js', plugin_dir_url( __FILE__ ) . 'js/acfblocks.js', array('jquery'), '', false );
},
));
// register a Price List block.
acf_register_block_type(array(
'name' => 'acfb-pricelist',
'mode' => 'preview',
'title' => __('Price List'),
'description' => __('Display price list for any product easily.'),
'render_template' => plugin_dir_path( __FILE__ ) . 'block-templates/price-list.php',
'category' => 'acfb-blocks',
'icon' => '',
'enqueue_assets' => function(){
wp_enqueue_style( 'acfb-blocks-css', plugin_dir_url( __FILE__ ) . 'css/acfblocks.css' );
},
));
// register a Click To Tweet block.
acf_register_block_type(array(
'name' => 'acfb-clicktotweet',
'mode' => 'preview',
'title' => __('Click To Tweet'),
'description' => __('Add a tweet-able quote to let your reader tweet with 1-click.'),
'render_template' => plugin_dir_path( __FILE__ ) . 'block-templates/click-to-tweet.php',
'category' => 'acfb-blocks',
'icon' => '',
'enqueue_assets' => function(){
wp_enqueue_style( 'acfb-blocks-css', plugin_dir_url( __FILE__ ) . 'css/acfblocks.css' );
},
));
// register a Post block.
acf_register_block_type(array(
'name' => 'acfb-posts',
'mode' => 'preview',
'title' => __('Posts'),
'description' => __('Display a grid or list of your blog posts.'),
'render_template' => plugin_dir_path( __FILE__ ) . 'block-templates/posts.php',
'category' => 'acfb-blocks',
'icon' => '',
'enqueue_assets' => function(){
wp_enqueue_style( 'acfb-blocks-css', plugin_dir_url( __FILE__ ) . 'css/acfblocks.css' );
},
));
// register a Photo Collage block.
acf_register_block(array(
'name' => 'acfb-photocollage',
'mode' => 'preview',
'title' => __('Photo Collage'),
'description' => __('Display beautiful photo collage using pre-made templates.'),
'render_template' => plugin_dir_path( __FILE__ ) . 'block-templates/photo-collage.php',
'category' => 'acfb-blocks',
'icon' => '',
'enqueue_assets' => function(){
wp_enqueue_style( 'acfb-blocks-css', plugin_dir_url( __FILE__ ) . 'css/acfblocks.css' );
},
));
}
}
// Save Acf
add_filter('acf/settings/save_json', 'acfb_json_save_point');
function acfb_json_save_point( $acfb_path ) {
// update path
$acfb_path = plugin_dir_path( __FILE__ ) . '/acf-json';
// return
return $acfb_path;
}
// Load Acf
add_filter('acf/settings/load_json', 'acfb_json_load_point');
function acfb_json_load_point( $acfb_path ) {
// remove original path (optional)
unset($acfb_path[0]);
// append path
$acfb_path[] = plugin_dir_path( __FILE__ ) . '/acf-json';
// return
return $acfb_path;
}
// Excerpt Limit
function acfb_excerpt($acfb_excerpt_limit) {
$acfb_excerpt = explode(' ', get_the_excerpt(), $acfb_excerpt_limit);
if (count($acfb_excerpt)>=$acfb_excerpt_limit) {
array_pop($acfb_excerpt);
$acfb_excerpt = implode(" ",$acfb_excerpt).'...';
} else {
$acfb_excerpt = implode(" ",$acfb_excerpt);
}
$acfb_excerpt = preg_replace('`[[^]]*]`','',$acfb_excerpt);
return $acfb_excerpt;
}
// Default Value in post List Elements
add_filter('acf/load_value/name=acfb_post_list_elements', 'acfb_post_list_elements_defaults', 10, 3);
function acfb_post_list_elements_defaults($value, $post_id, $field) {
if ($value !== NULL) {
// $value will only be NULL on a new post
return $value;
}
// add default layouts
$value = array(
array(
'acf_fc_layout' => 'post_list_title'
),
array(
'acf_fc_layout' => 'post_list_meta_data'
),
array(
'acf_fc_layout' => 'post_list_content'
),
array(
'acf_fc_layout' => 'post_list_read_more_button'
)
);
return $value;
}
// Default Value in post Grid Elements
add_filter('acf/load_value/name=acfb_post_grid_elements', 'acfb_post_grid_elements_defaults', 10, 3);
function acfb_post_grid_elements_defaults($value, $post_id, $field) {
if ($value !== NULL) {
// $value will only be NULL on a new post
return $value;
}
// add default layouts
$value = array(
array(
'acf_fc_layout' => 'post_grid_image'
),
array(
'acf_fc_layout' => 'post_grid_title'
),
array(
'acf_fc_layout' => 'post_grid_meta_data'
),
array(
'acf_fc_layout' => 'post_grid_content'
),
array(
'acf_fc_layout' => 'post_grid_read_more_button'
)
);
return $value;
}
add_filter('acf/load_field/name=2_grid_layouts', 'acfb_two_grid_icons');
function acfb_two_grid_icons( $field ) {
$field['choices'] = array(
'one' => '
',
'two' => '
'
);
return $field;
}
add_filter('acf/load_field/name=3_grid_layouts', 'acfb_three_grid_icons');
function acfb_three_grid_icons( $field ) {
$field['choices'] = array(
'one' => '
',
'two' => '
',
'three' => '
',
'four' => '
',
'five' => '
',
'six' => '
'
);
return $field;
}
add_filter('acf/load_field/name=4_grid_layouts', 'acfb_four_grid_icons');
function acfb_four_grid_icons( $field ) {
$field['choices'] = array(
'one' => '
',
'two' => '
',
'three' => '
',
'four' => '
',
'five' => '
',
'six' => '
',
'seven' => '
',
'eight' => '
',
'nine' => '
',
'ten' => '
',
'eleven' => '
',
'twelve' => '
',
'thirteen' => '
',
'fourteen' => '
',
'fifteen' => '
',
);
return $field;
}