menu = apply_filters('mfn-opts-menu', $menu);
$defaults = array();
$defaults['opt_name'] = 'betheme';
$defaults['menu_icon'] = MFN_OPTIONS_URI .'/img/menu_icon.png';
$defaults['menu_title'] = __('Theme Options', 'mfn-opts');
$defaults['page_title'] = __('Theme Options', 'mfn-opts');
$defaults['page_slug'] = apply_filters('betheme_slug', 'be').'-options';
$defaults['page_cap'] = 'edit_theme_options';
$defaults['page_type'] = 'menu';
$defaults['page_parent'] = '';
$defaults['page_position'] = 100;
// get args
$this->args = $defaults;
$this->args = apply_filters( 'mfn-opts-args', $this->args );
$this->args = apply_filters( 'mfn-opts-args-'. $this->args['opt_name'], $this->args );
// get sections
$this->sections = apply_filters( 'mfn-opts-sections', $sections );
$this->sections = apply_filters( 'mfn-opts-sections-'. $this->args['opt_name'], $this->sections );
// set option with defaults
add_action( 'init', array( $this, '_set_default_options' ) );
add_action( 'init', array( $this, '_backward_compatibility' ) );
// save new custom fonts
add_action( 'init', array( $this, '_register_custom_social' ), 11 );
add_action( 'init', array( $this, '_register_custom_fonts' ), 12 );
// options page
add_action( 'admin_menu', array( $this, '_options_page' ), 4 );
add_filter( 'admin_body_class', array( $this, '_admin_body_class' ) );
// register setting
add_action( 'admin_init', array( $this, '_register_setting' ) );
// get the options for use later on
$this->options = get_option( $this->args['opt_name'] );
if( empty( $_GET['action'] ) || $_GET['action'] != apply_filters('betheme_slug', 'mfn') .'-live-builder' ){
// first action hooked into the admin scripts actions
add_action( 'admin_enqueue_scripts', array( $this, '_enqueue' ) );
}
// hook into the wp feeds for downloading the exported settings
add_action( 'do_feed_mfn-opts-'. $this->args['opt_name'], array( $this, '_download_options' ), 1, 1 );
// add actions before form
add_action( 'mfn-opts-page-before-form', array( $this, '_static_CSS' ), 10 );
add_action( 'mfn-opts-page-before-form', array( $this, '_cache_manager' ), 11 );
add_action( 'mfn-opts-page-before-form', array( $this, '_flush_cache' ), 12 );
// ajax
add_action( 'wp_ajax_mfn_options_revision_save', array( $this, '_revision_save' ) );
}
/**
* Ajax | SET revision
*/
public function _revision_save(){
// function verifies the AJAX request, to prevent any processing of requests which are passed in by third-party sites or systems
check_ajax_referer( 'mfn-builder-nonce', 'mfn-builder-nonce' );
if( ! current_user_can( 'manage_options' ) ){
wp_die();
}
if( empty( $_POST['betheme'] ) ){
return false;
}
$options = $_POST['betheme'];
$type = htmlspecialchars(trim($_POST['revision-type']));
unset( $options['last_tab'] );
unset( $options['import_code'] );
unset( $options['import_link'] );
$revisions = $this->set_revision( $type, $options );
echo $this->get_revisions_json( $revisions );
exit;
}
/**
* SET revision
*/
public function set_revision( $type, $options ){
if( ! $type || ! $options ){
return false;
}
$options = call_user_func('base'.'64_encode', serialize($options));
$limit = 5; // max number of revisions of specified type
$option_key = 'betheme_revision_'. $type;
$revisions = get_option( $option_key );
if( $revisions && is_array($revisions) ){
if( count( $revisions ) >= $limit ){
reset( $revisions );
$rev_key = key( $revisions );
unset( $revisions[$rev_key] );
}
} else {
$revisions = [];
}
$time = current_time('timestamp');
$revisions[$time] = $options;
update_option( $option_key, $revisions );
return $revisions;
}
/**
* GET revisions in json format
*/
public function get_revisions_json( $revisions ){
if( ! is_array( $revisions ) ){
return false;
}
$date_format = get_option( 'date_format' );
$time_format = get_option( 'time_format' );
$json = [];
foreach( $revisions as $rev_key => $rev_val ){
$json[$rev_key] = date( $date_format .' '. $time_format , $rev_key );
}
return json_encode($json);
}
/**
* Get all revisions for the post
*/
public function get_revisions(){
$array = [
'update' => [],
'revision' => [],
'backup' => [],
];
$date_format = get_option( 'date_format' );
$time_format = get_option( 'time_format' );
foreach( $array as $type => $value ){
$option_key = 'betheme_revision_'. $type;
$revisions = get_option( $option_key );
if( is_array( $revisions ) ){
foreach( $revisions as $rev_key => $rev_val ){
$array[$type][$rev_key] = date( $date_format .' '. $time_format , $rev_key );
}
}
}
return $array;
}
/**
* Print revisions list
*/
public function the_revisions_list( $revisions ){
if( ! empty( $revisions ) ){
foreach( $revisions as $rev_key => $rev_val ){
echo '
';
echo '';
echo '';
echo '';
}
}
}
/**
* Get darker color
* Helper function for old button styles
*/
public function get_darker_color($hex, $percentage) {
// Ensure hex is formatted correctly
$hex = str_replace('#', '', $hex);
// If shorthand notation, expand it
if (strlen($hex) == 3) {
$hex = str_repeat(substr($hex, 0, 1), 2) .
str_repeat(substr($hex, 1, 1), 2) .
str_repeat(substr($hex, 2, 1), 2);
}
// Convert hex to RGB
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));
// Calculate the step value based on the percentage
$steps = round(255 * ($percentage / 100));
// Adjust brightness to make the color darker
$r = max(0, min(255, $r - $steps));
$g = max(0, min(255, $g - $steps));
$b = max(0, min(255, $b - $steps));
// Convert RGB back to hex
$r = str_pad(dechex($r), 2, '0', STR_PAD_LEFT);
$g = str_pad(dechex($g), 2, '0', STR_PAD_LEFT);
$b = str_pad(dechex($b), 2, '0', STR_PAD_LEFT);
return "#$r$g$b";
}
/**
* Backward compatibility with older Betheme versions
* @since 21.9.1
*/
public function _backward_compatibility(){
if( ! is_array($this->options) ){
$this->options = [];
}
// Minimalist header @since 21.9.1
if( isset( $this->options['minimalist-header'] ) ) {
if( 'no' === $this->options['minimalist-header'] ) {
$this->options['header-height'] = '0'; // use string not integer
$this->options['mobile-subheader-padding'] = '80px 0';
} elseif( '1' === $this->options['minimalist-header'] ) {
$this->options['header-height'] = '0';
if( 'modern' == $this->options['header-style'] ){
$this->options['header-height'] = '147';
}
if( 'simple' == $this->options['header-style'] ){
$this->options['header-height'] = '130';
}
if( 'fixed' == $this->options['header-style'] ){
$this->options['header-height'] = '60';
}
} else {
$this->options['header-height'] = '250';
}
}
// Custom Variation Swatches @since 25.0.3
if( ! isset( $this->options['variable-swatches'] ) ) {
$this->options['variable-swatches'] = '1';
}
// Social icons order @since 25.1.6
$socials = ['skype','whatsapp','facebook','twitter','vimeo','youtube','flickr','linkedin','pinterest','dribbble','instagram','snapchat','behance','tumblr','tripadvisor','vkontakte','viadeo','xing','custom','rss'];
if( empty( $this->options['social-link']['order'] ) ) {
$this->options['social-link'] = [];
$this->options['social-link']['order'] = implode( ',', $socials );
}
foreach( $socials as $social ){
if( isset( $this->options['social-'. $social] ) ) {
$this->options['social-link'][$social] = $this->options['social-'. $social];
}
}
// Buttons 2.0 @since 27.4.2
if( isset( $this->options['button-style'] ) ) {
$this->options['button-animation'] = 'fade';
$this->options['button-animation-time'] = 0.2;
// custom
if( 'custom' == $this->options['button-style'] ){
$this->options['button-icon-color'] = $this->options['button-color'];
$this->options['button-highlighted-icon-color'] = $this->options['button-highlighted-color'];
$this->options['button-action-icon-color'] = $this->options['button-action-color'];
$this->options['button-shop-color'] = $this->options['button-highlighted-color'];
$this->options['button-shop-background'] = $this->options['button-highlighted-background'];
$this->options['button-shop-border-color'] = $this->options['button-highlighted-border-color'];
$this->options['button-shop-box-shadow'] = $this->options['button-highlighted-box-shadow'] ?? '';
}
// all buttons, except 'custom' - used content font
if( 'custom' != $this->options['button-style'] ){
$this->options['button-font-family'] = '';
$this->options['button-font'] = $this->options['font-size-content'];
$this->options['button-padding'] = [
'top' => '16px',
'right' => '20px',
'bottom' => '16px',
'left' => '20px',
];
$this->options['button-border-width'] = '';
$this->options['button-border-color'] = '';
$this->options['button-box-shadow'] = '';
$this->options['button-highlighted-border-color'] = '';
$this->options['button-highlighted-box-shadow'] = '';
$this->options['button-shop-border-color'] = '';
$this->options['button-shop-box-shadow'] = '';
$this->options['button-action-border-color'] = '';
$this->options['button-action-box-shadow'] = '';
// classic, flat, round
if( in_array( $this->options['button-style'], ['', 'flat', 'round'] ) ){
if( '' == $this->options['button-style'] ){
$this->options['button-border-radius'] = '5px';
} elseif( 'flat' == $this->options['button-style'] ){
$this->options['button-border-radius'] = '0';
} elseif( 'round' == $this->options['button-style'] ){
$this->options['button-border-radius'] = '50px';
$this->options['button-padding']['right'] = '35px';
$this->options['button-padding']['left'] = '35px';
}
// default
$this->options['button-color'] = [
'normal' => $this->options['color-button'] ?? '#747474',
'hover' => $this->options['color-button'] ?? '#747474',
];
$this->options['button-background'] = [
'normal' => $this->options['background-button'] ?? '#f7f7f7',
'hover' => $this->options['background-button'] ?? '#f7f7f7',
];
$this->options['button-icon-color'] = $this->options['button-color'];
// theme
$this->options['button-highlighted-color'] = [
'normal' => $this->options['color-button-theme'] ?? '#FFFFFF',
'hover' => $this->options['color-button-theme'] ?? '#FFFFFF',
];
$this->options['button-highlighted-background'] = [
'normal' => $this->options['color-theme'] ?? '#0089F7',
'hover' => $this->options['color-theme'] ?? '#0089F7',
];
$this->options['button-highlighted-icon-color'] = $this->options['button-highlighted-color'];
// shop
$this->options['button-shop-color'] = $this->options['button-highlighted-color'];
$this->options['button-shop-background'] = $this->options['button-highlighted-background'];
// action
$this->options['button-action-color'] = [
'normal' => $this->options['color-action-button'] ?? '#FFFFFF',
'hover' => $this->options['color-action-button'] ?? '#FFFFFF',
];
$this->options['button-action-background'] = [
'normal' => $this->options['background-action-button'] ?? '#0089F7',
'hover' => $this->options['background-action-button'] ?? '#0089F7',
];
$this->options['button-action-icon-color'] = $this->options['button-action-color'];
// auto hover darker colors
$this->options['button-background']['hover'] = $this->get_darker_color($this->options['button-background']['normal'], 5);
$this->options['button-highlighted-background']['hover'] = $this->get_darker_color($this->options['button-highlighted-background']['normal'], 5);
$this->options['button-shop-background']['hover'] = $this->get_darker_color($this->options['button-shop-background']['normal'], 5);
$this->options['button-action-background']['hover'] = $this->get_darker_color($this->options['button-action-background']['normal'], 5);
}
// default - old hover style
if( '' == $this->options['button-style'] ){
$this->options['button-animation'] = 'slide slide-right';
}
// stroke
if( 'stroke' == $this->options['button-style'] ){
$this->options['button-border-radius'] = '3px';
$this->options['button-border-width'] = '2px';
// default
$this->options['button-color'] = [
'normal' => $this->options['color-button'] ?? '#747474',
'hover' => '#FFFFFF',
];
$this->options['button-background'] = [
'normal' => '',
'hover' => $this->options['background-button'] ?? '#f7f7f7',
];
$this->options['button-border'] = [
'normal' => $this->options['background-button'] ?? '#f7f7f7',
'hover' => $this->options['background-button'] ?? '#f7f7f7',
];
$this->options['button-icon-color'] = $this->options['button-color'];
// theme
$this->options['button-highlighted-color'] = [
'normal' => $this->options['color-theme'] ?? '#0089F7',
'hover' => '#000000',
];
$this->options['button-highlighted-background'] = [
'normal' => '',
'hover' => $this->options['color-theme'] ?? '#0089F7',
];
$this->options['button-highlighted-border'] = [
'normal' => $this->options['color-theme'] ?? '#0089F7',
'hover' => $this->options['color-theme'] ?? '#0089F7',
];
$this->options['button-highlighted-icon-color'] = $this->options['button-highlighted-color'];
// shop
$this->options['button-shop-color'] = $this->options['button-highlighted-color'];
$this->options['button-shop-background'] = $this->options['button-highlighted-background'];
$this->options['button-shop-border'] = $this->options['button-highlighted-border'];
// action
$this->options['button-action-color'] = [
'normal' => $this->options['color-action-button'] ?? '#0089F7',
'hover' => '#000000',
];
$this->options['button-action-background'] = [
'normal' => '',
'hover' => $this->options['background-action-button'] ?? '#0089F7',
];
$this->options['button-action-border'] = [
'normal' => $this->options['background-action-button'] ?? '#0089F7',
'hover' => $this->options['background-action-button'] ?? '#0089F7',
];
$this->options['button-action-icon-color'] = $this->options['button-action-color'];
}
}
}
// Lead text @since 27.5.8
if( ! isset( $this->options['font-lead'] ) ) {
$this->options['font-lead'] = $this->options['font-content'] ?? '';
}
}
/**
* This is used to return and option value from the options array
*/
public function get( $opt_name, $default = null ) {
if( ! is_array( $this->options ) ){
return $default;
}
if( ! key_exists( $opt_name, $this->options ) ){
return $default;
}
if( empty( $this->options[$opt_name] ) && ( '0' !== $this->options[$opt_name] ) ){
return $default;
}
return $this->options[$opt_name];
}
/**
* Get default options into an array suitable for the settings API
*/
public function _default_values()
{
$defaults = array();
foreach ( $this->sections as $k => $section ) {
if ( isset( $section['fields'] ) ) {
foreach ( $section['fields'] as $fieldk => $field ) {
if ( empty( $field['id'] ) ){
continue;
}
if ( ! isset( $field['std'] ) ) {
$field['std'] = '';
}
$defaults[ $field['id'] ] = $field['std'];
}
}
}
$defaults['last_tab'] = false;
return $defaults;
}
/**
* Set default options on admin_init if option doesnt exist (theme activation hook caused problems, so admin_init it is)
*/
public function _set_default_options()
{
if ( ! get_option($this->args['opt_name']) ) {
add_option($this->args['opt_name'], $this->_default_values());
}
$this->options = get_option($this->args['opt_name']);
// be setup wizard
if( isset( $_GET['mfn-setup-preview'] ) ){
$this->options = $this->_default_values();
}
}
/**
* Class Theme Options Page Function, creates main options page.
*/
public function _options_page()
{
$this->page = add_submenu_page(
apply_filters('betheme_dynamic_slug', 'betheme'),
$this->args['page_title'],
$this->args['page_title'],
$this->args['page_cap'],
apply_filters('betheme_slug', 'be').'-options',
array( $this, '_options_page_html' )
);
// Fires when styles are printed for a specific admin page based on $hook_suffix.
add_action( 'admin_print_styles-'. $this->page, array( $this, '_enqueue_options_page' ) );
}
/**
* Admin body class
* @param string $classes
*/
public function _admin_body_class( $classes )
{
$classes .= ' theme_page_be-options';
// elementor active - show some of theme options
if ( class_exists( 'Elementor\Plugin' ) ){
$classes .= ' elementor-active';
}
// load google fonts
if ( mfn_opts_get('google-font-mode') !== 'disabled' ) {
$classes .= ' has-googlefonts';
}
// hide wordpress editor
if ( mfn_opts_get('hide_editor') ) {
$classes .= ' hide-wp-editor';
}
// UI options
$ui_options = Mfn_Builder_Helper::get_options();
$screen = get_current_screen();
$screen_base = '';
if( is_object( $screen ) ){
$screen_base = $screen->base;
// templates edit screen
if( 'edit' == $screen_base && 'template' == $screen->post_type ){
$screen_base = 'template_edit';
}
}
$slug_betheme = apply_filters('betheme_slug', 'betheme');
$slug_be = apply_filters('betheme_slug', 'be');
$be_dark = array(
'toplevel_page_'. $slug_betheme,
$slug_betheme .'_page_'. $slug_be .'-setup',
$slug_betheme .'_page_'. $slug_be .'-plugins',
$slug_betheme .'_page_'. $slug_be .'-websites',
$slug_betheme .'_page_'. $slug_be .'-options',
$slug_betheme .'_page_'. $slug_be .'-status',
$slug_betheme .'_page_'. $slug_be .'-support',
$slug_betheme .'_page_'. $slug_be .'-changelog',
$slug_betheme .'_page_'. $slug_be .'-tools',
'template_edit',
);
// dark mode
if( ! empty( $ui_options['dashboard-ui'] ) && 'dark' == $ui_options['dashboard-ui'] && in_array( $screen_base, $be_dark ) ){
$classes .= ' mfn-ui-dark';
} else {
$classes .= ' mfn-ui-light';
}
return $classes;
}
/**
* Enqueue styles/js GLOBAL
*/
public function _enqueue()
{
// styles
if ( ! mfn_opts_get('google-font-mode') ) {
wp_enqueue_style('mfn-opts-font', 'https://fonts.googleapis.com/css?family=Poppins:300,400,500,600', false, MFN_THEME_VERSION, 'all');
} elseif ( 'local' === mfn_opts_get( 'google-font-mode' ) ) {
$path_fonts = mfn_uploads_dir('baseurl', 'fonts');
wp_enqueue_style('mfn-opts-font', $path_fonts.'/mfn-local-fonts.css', false, MFN_THEME_VERSION, 'all');
}
wp_enqueue_style('mfn-opts-fontawesome', get_theme_file_uri('/fonts/fontawesome/fontawesome.css'), false, MFN_THEME_VERSION, 'all');
wp_enqueue_style('mfn-opts-icons', get_theme_file_uri('/fonts/mfn/icons.css'), false, MFN_THEME_VERSION, 'all');
wp_enqueue_style('mfn-opts', $this->url .'css/options.css', false, MFN_THEME_VERSION, 'all');
// magnific popup
wp_enqueue_style( 'mfn-magnific-popup', get_theme_file_uri('/functions/admin/assets/plugins/magnific-popup/magnific-popup.css'), array(), MFN_THEME_VERSION );
wp_enqueue_script( 'mfn-magnific-popup', get_theme_file_uri('/functions/admin/assets/plugins/magnific-popup/magnific-popup.min.js'), false, MFN_THEME_VERSION, true );
// scripts
wp_enqueue_script( 'mfn-opts-plugins', $this->url .'js/plugins.js', array('jquery'), MFN_THEME_VERSION, true );
wp_register_script( 'mfn-opts-js', $this->url .'js/options.js', array('jquery'), MFN_THEME_VERSION, true );
$screen = get_current_screen();
if( is_object( $screen ) && 'toplevel_page_revslider' !== $screen->base ){
// syntax highlight
$cm_args = array(
'autoRefresh' => true,
'lint' => true,
'indentUnit' => 2,
'tabSize' => 2,
);
$codemirror['css']['codeEditor'] = wp_enqueue_code_editor(array(
'type' => 'text/css', // required for lint
'codemirror' => $cm_args,
));
$codemirror['html']['codeEditor'] = wp_enqueue_code_editor(array(
'type' => 'text/html', // required for lint
'codemirror' => $cm_args,
));
$codemirror['javascript']['codeEditor'] = wp_enqueue_code_editor(array(
'type' => 'javascript', // required for lint
'codemirror' => $cm_args,
));
wp_localize_script( 'mfn-opts-js', 'mfn_cm', $codemirror );
}
// color palette
$palette = [];
for ( $i=1; $i <= 14; $i++ ) {
if( ! empty( $this->options['color-palette-'. $i] ) ){
$palette[] = $this->options['color-palette-'. $i];
}
}
if( empty($palette) ){
$palette = ["#e91e63","#9c27b0","#673ab7","#3f51b5","#2196f3","#03a9f4","#00bcd4","#009688","#4caf50","#8bc34a","#cddc39","#ffeb3b","#ffc107"];
}
wp_localize_script( 'mfn-opts-js', 'mfn_palette', $palette );
// enqueue
wp_enqueue_script( 'mfn-opts-js' );
}
/**
* Enqueue styles/js THEME OPTIONS only
*/
public function _enqueue_options_page()
{
wp_enqueue_style( 'mfn-dashboard', get_theme_file_uri('/functions/admin/assets/dashboard.css'), array(), MFN_THEME_VERSION );
wp_enqueue_script('mfn-dashboard', get_theme_file_uri('/functions/admin/assets/dashboard.js'), false, MFN_THEME_VERSION, true);
}
/**
* Download the options file, or display it
*/
public function _download_options()
{
if (! isset($_GET['secret']) || $_GET['secret'] != md5(AUTH_KEY.SECURE_AUTH_KEY)) {
wp_die('Invalid Secret for options use');
exit;
}
if (! isset($_GET['feed'])) {
wp_die('No Feed Defined');
exit;
}
$backup_options = get_option(str_replace('mfn-opts-', '', $_GET['feed']));
$backup_options['mfn-opts-backup'] = '1';
$backup_options = json_encode($backup_options);
if (isset($_GET['action']) && $_GET['action'] == 'download_options') {
header('Content-Description: File Transfer');
header('Content-type: application/txt');
header('Content-Disposition: attachment; filename="'. str_replace('mfn-opts-', '', $_GET['feed']) .'_options_'. date('d-m-Y') .'.txt"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
echo $backup_options;
exit;
} else {
echo $backup_options;
exit;
}
}
/**
* Static CSS
*/
public function _static_CSS()
{
if( empty($_GET['settings-updated']) || empty($this->options['static-css']) ){
return false;
};
$wp_filesystem = Mfn_Helper::filesystem();
$upload_dir = wp_upload_dir();
$path_be = wp_normalize_path( $upload_dir['basedir'] .'/betheme' );
$path_css = wp_normalize_path( $path_be .'/css' );
$path = wp_normalize_path( $path_css .'/static.css' );
if( ! file_exists( $path_be ) ){
wp_mkdir_p( $path_be );
}
if( ! file_exists( $path_css ) ){
wp_mkdir_p( $path_css );
}
$css = "/* theme options */\n";
$css .= mfn_styles_dynamic();
$wp_filesystem->put_contents( $path, $css, FS_CHMOD_FILE );
}
/**
* Flush W3 Total Cache
*/
public function _flush_cache()
{
if( empty($_GET['settings-updated']) ){
return false;
};
if ( function_exists('w3tc_flush_all') ){
w3tc_flush_all();
}
// generate bebuilder file
if( empty( $this->options['builder-visibility'] ) || 'hide' !== $this->options['builder-visibility'] ){
Mfn_Helper::generate_bebuilder_items();
}
}
/**
* Caching
*/
public function _cache_manager()
{
$cache_created = get_transient('betheme_hold-cache');
$cache_activate = intval(mfn_opts_get('hold-cache'));
if( 'changed' == $cache_created ){
if ( $cache_activate ) {
$this->_setup_cache();
delete_transient('betheme_hold-cache');
@clearstatcache();
} else {
$this->_remove_cache();
delete_transient('betheme_hold-cache');
@clearstatcache();
}
}
}
public function _setup_cache()
{
if( empty($_GET['settings-updated'] ) || ! mfn_opts_get('hold-cache') ) {
return false;
}
$wp_filesystem = Mfn_Helper::filesystem();
$htaccess_path = get_home_path() .'.htaccess';
$htaccess_content = $wp_filesystem->get_contents($htaccess_path);
$htaccess_new_content = $htaccess_content . Mfn_Helper::get_cache_text();
$wp_filesystem->put_contents($htaccess_path, $htaccess_new_content, 0644);
}
public function _remove_cache()
{
$wp_filesystem = Mfn_Helper::filesystem();
$htaccess_path = get_home_path() .'.htaccess';
$htaccess_content = $wp_filesystem->get_contents($htaccess_path);
$htaccess_new_content = preg_replace('/(# BEGIN BETHEME)(.|\n)*?(# END BETHEME)/', '', $htaccess_content);
$wp_filesystem->put_contents($htaccess_path, $htaccess_new_content, 0644);
}
/**
* Theme Options -> Social -> Custom
* Save only filled fields (dynamically added)
*/
public function _register_custom_social()
{
if( empty( $this->options['custom-icon-count'] ) ){
return false;
};
$number_loaded = 2; // we start from 2, because 1 custom icon is default
$custom_amount = intval( $this->options['custom-icon-count'] ) + $number_loaded;
$loop = 2; // we start from 2, because 1 custom icon is default
for( $loop; $loop < $custom_amount; $loop++ ){
if ( ! empty( $this->options['social-custom-icon-'. $loop] ) ) {
$this->options['social-custom-icon-'. $number_loaded] = $this->options['social-custom-icon-'. $loop];
$this->options['social-custom-link-'. $number_loaded] = $this->options['social-custom-link-'. $loop];
$this->options['social-custom-title-'. $number_loaded] = $this->options['social-custom-title-'. $loop];
// increase flag, it means one custom dynamically social is loaded
$number_loaded++;
} else {
// Empty ALL values if icon is not provided
$this->options['social-custom-icon-'. $loop] = '';
$this->options['social-custom-link-'. $loop] = '';
$this->options['social-custom-title-'. $loop] = '';
// remove icon from social order field
if( ! empty( $this->options['social-link']['order'] ) ){
$name = 'custom-'. $number_loaded;
$names = [
$name .',',
','. $name,
]; // removes also "," sign
$this->options['social-link']['order'] = str_replace($names, '', $this->options['social-link']['order']);
}
}
}
// update the new fields amount, to know how many fields have to appear
$this->options['custom-icon-count'] = $number_loaded - 2;
}
/**
* Theme Options -> Fonts -> Custom
* Save only filled fields (dynamically added)
*/
public function _register_custom_fonts()
{
if( ! mfn_opts_get('font-custom-fields') ){
return false;
};
$font_number_loaded = 3; // we start from 3, because 2 custom fonts are default ones
$loop = 3; // we start from 3, because 2 custom fonts are default ones
$custom_amount = intval(mfn_opts_get('font-custom-fields')) + $loop;
for( $loop; $loop < $custom_amount; $loop++ ){
if ( ! empty( mfn_opts_get( 'font-custom'. $loop ) ) ) {
// Overwrite the most early font field, with values from field
$this->options['font-custom'. $font_number_loaded] = mfn_opts_get( 'font-custom'. $loop );
$this->options['font-custom'. $font_number_loaded .'-woff'] = mfn_opts_get( 'font-custom'. $loop .'-woff' );
$this->options['font-custom'. $font_number_loaded .'-ttf' ] = mfn_opts_get( 'font-custom'. $loop .'-ttf' );
// increase flag, it means one custom dynamically font is loaded.
$font_number_loaded++;
} else {
// Empty ALL values if title is not provided
$this->options['font-custom'. $loop] = '';
$this->options['font-custom'. $loop .'-woff'] = '';
$this->options['font-custom'. $loop .'-ttf'] = '';
}
}
// update the new fields amount, to know how many fields have to appear
$this->options['font-custom-fields'] = $font_number_loaded - 3;
}
/**
* Validate the Options options before insertion
*/
public function _validate_options($plugin_options)
{
set_transient('mfn-opts-saved', '1', 1000);
// options | revision restore
if( ! empty( $_POST['revision-time'] ) ){
$time = htmlspecialchars(trim($_POST['revision-time']));
$type = htmlspecialchars(trim($_POST['revision-type']));
if( $time && $type ){
$option_key = 'betheme_revision_'. $type;
$revisions = get_option( $option_key );
if( ! empty( $revisions[$time] ) ){
$options = $revisions[$time];
$options = unserialize(base64_decode($options), ['allowed_classes' => false]);
return $options;
}
}
}
// options | import
if (! empty($plugin_options['import'])) {
if ($plugin_options['import_code'] != '') {
// import from file
$import = $plugin_options['import_code'];
} elseif ($plugin_options['import_link'] != '') {
// import from URL
$import = wp_remote_retrieve_body(wp_safe_remote_get($plugin_options['import_link']));
}
$imported_options = json_decode($import, true);
// FIX | Import 1-click Demo Data encoded options file
if ($imported_options === false) {
$import_tmp_fn = 'base'.'64_decode';
$import = call_user_func($import_tmp_fn, trim($import));
$imported_options = unserialize($import, ['allowed_classes' => false]);
}
if (is_array($imported_options)) {
$imported_options['imported'] = 1;
$imported_options['last_tab'] = false;
return $imported_options;
}
}
// options | defaults
if (isset($plugin_options['defaults']) && ($plugin_options['defaults'] == 'Resetting...')) {
$plugin_options = $this->_default_values();
return $plugin_options;
}
// validate fields (if needed)
$plugin_options = $this->_validate_values($plugin_options, $this->options);
// save revision
$this->set_revision( 'update', $plugin_options);
// JS error handling
if ( $this->errors ) {
set_transient( 'mfn-opts-errors', $this->errors, 1000 );
}
if ( $this->warnings ) {
set_transient( 'mfn-opts-warnings', $this->warnings, 1000 );
}
// after validate hooks
do_action('mfn-opts-options-validate', $plugin_options, $this->options);
do_action('mfn-opts-options-validate-'.$this->args['opt_name'], $plugin_options, $this->options);
// unset unwanted attributes
if( ! wp_doing_ajax() ){
unset($plugin_options['defaults']);
unset($plugin_options['import']);
unset($plugin_options['import_code']);
unset($plugin_options['import_link']);
}
return $plugin_options;
}
/**
* Validate values from options form (used in settings api validate function)
* calls the custom validation class for the field so authors can override with custom classes
*/
public function _validate_values($plugin_options, $options)
{
foreach ($this->sections as $k => $section) {
if (isset($section['fields'])) {
foreach ($section['fields'] as $fieldk => $field) {
$field['section_id'] = $k;
if ( empty( $field['id'] ) || empty( $plugin_options[$field['id']] ) ) {
continue;
}
// force validate of specified filed types
/*
if (isset($field[ 'type' ]) && ! isset($field[ 'validate' ])) {
if ($field[ 'type' ] == 'color' || $field[ 'type' ] == 'color_multi') {
$field[ 'validate' ] = 'color';
}
}
*/
// validate fields
if ( isset($field['validate']) ) {
$validate = 'MFN_Validation_'.$field['validate'];
if (! class_exists($validate)) {
require_once($this->dir .'validation/'. $field['validate'] .'/validation_'. $field[ 'validate' ] .'.php');
}
if (class_exists($validate)) {
$validation = new $validate($field, $plugin_options[ $field['id'] ], $options[ $field['id'] ]);
$plugin_options[ $field['id'] ] = $validation->value;
if (isset($validation->error)) {
$this->errors[] = $validation->error;
}
if (isset($validation->warning)) {
$this->warnings[] = $validation->warning;
}
continue;
}
}
if (isset($field['validate_callback']) && function_exists($field['validate_callback'])) {
$callbackvalues = call_user_func($field['validate_callback'], $field, $plugin_options[$field['id']], $options[$field['id']]);
$plugin_options[$field['id']] = $callbackvalues['value'];
if (isset($callbackvalues['error'])) {
$this->errors[] = $callbackvalues['error'];
}
if (isset($callbackvalues['warning'])) {
$this->warnings[] = $callbackvalues['warning'];
}
}
}
}
}
return $plugin_options;
}
/**
* Register settings
* Add setting section
*/
public function _register_setting()
{
require_once( $this->dir .'fields/class-mfn-options-field.php' );
register_setting( $this->args['opt_name'] .'_group', $this->args['opt_name'], array( $this, '_validate_options' ) );
foreach ( $this->sections as $k => $section ) {
add_settings_section( $k .'_section', $section['title'], false, $k .'_page' );
if ( isset( $section['fields'] ) ) {
foreach ( $section['fields'] as $field_key => $field ) {
if ( isset( $field['title'] ) ) {
// Muffin -> Custom label
$field['title'] = apply_filters('betheme_options_filed_title', $field['title']);
$th = isset( $field['sub_desc'] ) ? $field['title'] .''. $field['sub_desc'] .'' : $field['title'];
} else {
$th = '';
}
// Muffin -> Custom label
if ( isset($field['options']) ) {
$field['options'] = apply_filters('betheme_options_filed_options', $field['options']);
}
// both below for removing links and changing anchors
if ( isset($field['sub_desc']) ) {
$field['sub_desc'] = apply_filters('betheme_options_filed_desc', $field['sub_desc']);
}
if ( isset($field['desc']) ) {
$field['desc'] = apply_filters('betheme_options_filed_desc', $field['desc']);
}
add_settings_field( $field_key .'_field', $th, array( $this, '_field_input' ), $k .'_page', $k .'_section', $field );
}
}
}
}
/**
* Add setting field
*/
function _field_input( $field ){
if( empty( $field['type'] ) || $field['type'] == 'header' ){
return false;
}
$field_class = 'MFN_Options_'. $field['type'];
if ( ! class_exists( $field_class ) ) {
require_once( $this->dir .'fields/'. $field['type'] .'/field_'. $field['type'] .'.php' );
}
if( class_exists( $field_class ) ){
if( isset( $this->options[$field['id']] ) ){
$value = $this->options[$field['id']];
} else {
$value = isset($field['std']) ? $field['std'] : '';
}
$field_object = new $field_class( $field, $value, $this->args['opt_name'] );
$field_object->render();
// enqueue field JS and optional CSS
if( method_exists( $field_class, 'enqueue' ) ){
$field_object->enqueue();
}
}
}
/**
* Open options card HTML
*/
function card_open( $title, $args = [] ){
$class = false;
$param = false;
$id = str_replace( ' ', '-', strtolower( $title ) );
$id = str_replace( '&-', '', strtolower( $id ) );
if( ! empty($args['prefix']) ){
$id .= '-'. $args['prefix'];
}
$title = str_replace( '_', '', $title ); // duplicated names
// class
if( ! empty( $args['class'] ) ){
$class = $args['class'];
}
// parameters
if( ! empty( $args['attr'] ) ){
$param = 'data-attr="'. $args['attr'] .'"';
}
// output -----
echo '';
echo '';
echo '
';
echo '
';
}
/**
* Close options card HTML
*/
function card_close(){
echo '
';
echo '
';
echo '
';
}
/**
* Form row HTML
*/
function form_row( $field, $class = false ){
$conditions = '';
$row_class = '';
if( isset( $field['args']['responsive'] ) ){
$row_class .= 'mfn_field_'. $field['args']['responsive'];
}
if( isset( $field['args']['condition'] ) ){
$row_class .= ' activeif activeif-'. $field['args']['condition']['id'];
$conditions = 'data-id="'. $field['args']['condition']['id'] .'" data-opt="'. $field['args']['condition']['opt'] .'" data-val="'. $field['args']['condition']['val'] .'"';
}
echo '';
}
/**
* Custom do_settings_sections HTML
*/
function do_settings_sections( $page ) {
global $wp_settings_sections, $wp_settings_fields;
if ( ! isset( $wp_settings_sections[ $page ] ) ) {
return;
}
foreach ( (array) $wp_settings_sections[ $page ] as $section ) {
if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section['id'] ] ) ) {
continue;
}
$section_tab_id = str_replace( '_section', '', $section['id'] );
echo '';
$this->do_settings_fields( $page, $section );
$this->card_close();
echo '
';
}
}
/**
* Custom do_settings_fields HTML
*/
function do_settings_fields( $page, $section ) {
global $wp_settings_fields;
$section_id = $section['id'];
if ( ! isset( $wp_settings_fields[ $page ][ $section_id ] ) ) {
return;
}
// search results heading
$section_tab_id = str_replace( '_section', '', $section_id );
foreach ( $this->menu as $k => $item ) {
if (array_search( $section_tab_id, $item['sections']) !== false ) {
$parent_key = $k;
$parent_title = $item['title'];
break;
}
}
$title = $section['title'];
$link = 'admin.php?page=be-options#'. $section_tab_id;
echo '';
// loop thru fields
foreach ( (array) $wp_settings_fields[ $page ][ $section_id ] as $field ) {
$class = '';
if ( ! empty( $field['args']['class'] ) ) {
$class = $field['args']['class'];
}
if( empty( $field['args']['type'] ) || $field['args']['type'] == 'header' ){
// card wrapper
if( isset( $field['args']['join'] ) ){
$this->card_close();
}
if( ! isset( $field['args']['sub_desc'] ) ){
$field['args']['sub_desc'] = false;
}
/* Custom Custom Fonts -> Kinda like dynamic load */
if ( ! empty($field['args']['class']) && 'mfn_new_font' == $field['args']['class'] ) {
$this->custom_font_loader($field);
}
if ( ! empty($field['args']['class']) && 'custom-icon-card' == $field['args']['class'] ) {
$this->custom_social_loader($field);
}
$this->card_open( $field['args']['title'], $field['args'] );
} elseif( 'info' == $field['args']['type'] ) {
// info field
if( isset( $field['args']['join'] ) ){
$this->card_close();
}
call_user_func( $field['callback'], $field['args'] );
} else {
// fields
$this->form_row( $field, $class );
}
}
}
public function mfn_display_tmpl_conditions($conditions, $post_id = false, $tmpl_type = false) {
$html = '';
if( !empty($conditions) && is_iterable($conditions) ){
foreach($conditions as $c=>$con){
if($con->rule == 'include'){ $html .= '+ '; }else{ $html .= '- '; }
//print_r($con);
if($con->var == 'everywhere'){
$html .= 'Entire Site';
}elseif($con->var == 'archives'){
if( empty($con->archives) ){
$html .= 'All archives';
}else{
if( strpos($con->archives, ':') !== false){
$expl = explode(':', $con->archives);
$pt = get_post_type_object( $expl[0] );
$term = get_term( $expl[1] );
}elseif( !empty($con->archives) ){
$pt = get_post_type_object( $con->archives );
}
$html .= 'Archive: '.$pt->label;
if( !empty($term->name) ) $html .= '/'.$term->name;
}
}elseif($con->var == 'singular'){
if( empty($con->singular) ){
$html .= 'All singulars';
}else{
if( strpos($con->singular, ':') !== false){
$expl = explode(':', $con->singular);
$pt = get_post_type_object( $expl[0] );
$term = get_term( $expl[1] );
}elseif( !empty($con->singular) && $con->singular == 'front-page' ){
$html .= 'Front Page
';
continue;
}elseif( !empty($con->singular) ){
$pt = get_post_type_object( $con->singular );
}
$html .= 'Singular: '.$pt->label;
if( !empty($term->name) ) $html .= '/'.$term->name;
}
}elseif($con->var == 'shop'){
if( get_post_meta($post_id, 'mfn_template_type', true) == 'single-product' ){
$html .= ' All products';
}else{
$html .= ' Shop';
}
}elseif($con->var == 'productcategory'){
if($con->productcategory == 'all'){
$html .= ' All categories';
}else{
$term = get_term_by('term_id', $con->productcategory, 'product_cat');
if( !empty($term->name) ) $html .= 'Category: '.$term->name;
}
}elseif($con->var == 'producttag'){
if($con->producttag == 'all'){
$html .= ' All tags';
}else{
$term = get_term_by('term_id', $con->producttag, 'product_tag');
if( !empty($term->name) ) $html .= 'Tag: '.$term->name;
}
}elseif($con->var == 'all'){
if( $tmpl_type == 'blog' ){
$html .= 'Entire blog';
}elseif( $tmpl_type == 'portfolio' ){
$html .= 'Entire portfolio';
}else{
$html .= 'All singulars';
}
}elseif($con->var == 'category'){
$term = get_term_by('term_id', $con->category, 'category');
if( !empty($term->name) ) $html .= 'Category: '.$term->name;
}elseif($con->var == 'post_tag'){
$term = get_term_by('term_id', $con->post_tag, 'post_tag');
if( !empty($term->name) ) $html .= 'Tag: '.$term->name;
}elseif($con->var == 'portfolio-types'){
$term = get_term_by('term_id', $con->{'portfolio-types'}, 'portfolio-types');
if( !empty($term->name) ) $html .= 'Category: '.$term->name;
}
$html .= '
';
}
}else{
$html .= 'n/a';
}
return $html;
}
/**
* HTML OUTPUT
*/
function _options_page_html(){
global $wpdb;
$form_class = '';
$mfn_content_classes = array('mfn-content');
$header_tmpls = $wpdb->get_results( "SELECT p.ID, p.post_date, p.post_title, m.meta_value FROM {$wpdb->prefix}posts as p JOIN {$wpdb->prefix}postmeta as m on m.post_id = p.ID JOIN {$wpdb->prefix}postmeta as t on t.post_id = p.ID WHERE p.post_type = 'template' and p.post_status = 'publish' and m.meta_key = 'mfn_template_conditions' and t.meta_key = 'mfn_template_type' and t.meta_value = 'header' LIMIT 5" );
$footer_tmpls = $wpdb->get_results( "SELECT p.ID, p.post_date, p.post_title, m.meta_value FROM {$wpdb->prefix}posts as p JOIN {$wpdb->prefix}postmeta as m on m.post_id = p.ID JOIN {$wpdb->prefix}postmeta as t on t.post_id = p.ID WHERE p.post_type = 'template' and p.post_status = 'publish' and m.meta_key = 'mfn_template_conditions' and t.meta_key = 'mfn_template_type' and t.meta_value = 'footer' LIMIT 5" );
$shop_tmpls = $wpdb->get_results( "SELECT p.ID, p.post_date, p.post_title, m.meta_value FROM {$wpdb->prefix}posts as p JOIN {$wpdb->prefix}postmeta as m on m.post_id = p.ID JOIN {$wpdb->prefix}postmeta as t on t.post_id = p.ID WHERE p.post_type = 'template' and p.post_status = 'publish' and m.meta_key = 'mfn_template_conditions' and t.meta_key = 'mfn_template_type' and t.meta_value = 'shop-archive' LIMIT 5" );
$product_tmpls = $wpdb->get_results( "SELECT p.ID, p.post_date, p.post_title, m.meta_value FROM {$wpdb->prefix}posts as p JOIN {$wpdb->prefix}postmeta as m on m.post_id = p.ID JOIN {$wpdb->prefix}postmeta as t on t.post_id = p.ID WHERE p.post_type = 'template' and p.post_status = 'publish' and m.meta_key = 'mfn_template_conditions' and t.meta_key = 'mfn_template_type' and t.meta_value = 'single-product' LIMIT 5" );
$blog_tmpls = $wpdb->get_results( "SELECT p.ID, p.post_date, p.post_title, m.meta_value FROM {$wpdb->prefix}posts as p JOIN {$wpdb->prefix}postmeta as m on m.post_id = p.ID JOIN {$wpdb->prefix}postmeta as t on t.post_id = p.ID WHERE p.post_type = 'template' and p.post_status = 'publish' and m.meta_key = 'mfn_template_conditions' and t.meta_key = 'mfn_template_type' and t.meta_value = 'blog' LIMIT 5" );
$portfolio_tmpls = $wpdb->get_results( "SELECT p.ID, p.post_date, p.post_title, m.meta_value FROM {$wpdb->prefix}posts as p JOIN {$wpdb->prefix}postmeta as m on m.post_id = p.ID JOIN {$wpdb->prefix}postmeta as t on t.post_id = p.ID WHERE p.post_type = 'template' and p.post_status = 'publish' and m.meta_key = 'mfn_template_conditions' and t.meta_key = 'mfn_template_type' and t.meta_value = 'portfolio' LIMIT 5" );
$mfn_templates_html = '';
if( !empty($header_tmpls) ) {
$mfn_templates_html .= '';
}
if( !empty($shop_tmpls) ) {
$mfn_templates_html .= '';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
Your site uses Templates for Shop.
';
$mfn_templates_html .= 'Some options from the Theme Options may not work because they don\'t affect Templates.
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
You have '.count($shop_tmpls).' '.(count($shop_tmpls) == 1 ? 'used template:' : 'used templates:').'
Go to templates';
foreach( $shop_tmpls as $i=>$item ){
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
'.$item->post_date.'
';
$mfn_templates_html .= '
';
$conditions = !empty($item->meta_value) ? json_decode($item->meta_value) : array();
$shop_conditions = $this->mfn_display_tmpl_conditions($conditions, $item->ID);
$mfn_templates_html .= $shop_conditions;
if( strpos($shop_conditions, 'Shop') !== false ) $mfn_content_classes[] = 'mfn-content-has-shop-tmpls';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
}
$mfn_templates_html .= '
';
}
if( !empty($product_tmpls) ) {
$mfn_templates_html .= '';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
Your site uses Templates for Product.
';
$mfn_templates_html .= 'Some options from the Theme Options may not work because they don\'t affect Templates.
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
You have '.count($product_tmpls).' '.(count($product_tmpls) == 1 ? 'used template:' : 'used templates:').'
Go to templates';
foreach( $product_tmpls as $i=>$item ){
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
'.$item->post_date.'
';
$mfn_templates_html .= '
';
$conditions = !empty($item->meta_value) ? json_decode($item->meta_value) : array();
$product_conditions = $this->mfn_display_tmpl_conditions($conditions, $item->ID);
$mfn_templates_html .= $product_conditions;
if( strpos($product_conditions, 'All products') !== false ) $mfn_content_classes[] = 'mfn-content-has-product-tmpls';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
}
$mfn_templates_html .= '
';
}
if( !empty($footer_tmpls) ) {
$mfn_templates_html .= '';
}
if( !empty($blog_tmpls) ) {
$mfn_templates_html .= '';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
Your site uses Templates for Blog.
';
$mfn_templates_html .= 'Some options from the Theme Options may not work because they don\'t affect Templates.
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
You have '.count($blog_tmpls).' '.(count($blog_tmpls) == 1 ? 'used template:' : 'used templates:').'
Go to templates';
foreach( $blog_tmpls as $i=>$item ){
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
'.$item->post_date.'
';
$mfn_templates_html .= '
';
$conditions = !empty($item->meta_value) ? json_decode($item->meta_value) : array();
$blog_conditions = $this->mfn_display_tmpl_conditions($conditions, $item->ID, 'blog');
$mfn_templates_html .= $blog_conditions;
if( strpos($blog_conditions, 'Entire blog') !== false ) $mfn_content_classes[] = 'mfn-content-has-blog-tmpls';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
}
$mfn_templates_html .= '
';
}
if( !empty($portfolio_tmpls) ) {
$mfn_templates_html .= '';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
Your site uses Templates for Portfolio.
';
$mfn_templates_html .= 'Some options from the Theme Options may not work because they don\'t affect Templates.
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
You have '.count($portfolio_tmpls).' '.(count($portfolio_tmpls) == 1 ? 'used template:' : 'used templates:').'
Go to templates';
foreach( $portfolio_tmpls as $i=>$item ){
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
'.$item->post_date.'
';
$mfn_templates_html .= '
';
$conditions = !empty($item->meta_value) ? json_decode($item->meta_value) : array();
$portfolio_conditions = $this->mfn_display_tmpl_conditions($conditions, $item->ID, 'portfolio');
$mfn_templates_html .= $portfolio_conditions;
if( strpos($portfolio_conditions, 'Portfolio') !== false ) $mfn_content_classes[] = 'mfn-content-has-portfolio-tmpls';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
$mfn_templates_html .= '
';
}
$mfn_templates_html .= '
';
}
// theme skin
if( ! empty($this->options['skin']) && 'custom' != $this->options['skin'] ){
$form_class .= ' skin-selected';
}
// output
echo '';
}
/**
* Custom social loader
*/
public function custom_social_loader($field){
$loop = 2;
$custom_amount = intval(mfn_opts_get('custom-icon-count')) + $loop;
$callback = $field['callback'];
$class = '';
for( $loop; $loop < $custom_amount; $loop++ ){
$this->card_open( __('Custom '.$loop, 'mfn-opts'), array(
'args' => 'Custom '.$loop,
'join' => true,
) );
$this->form_row( array(
'args' => array(
'id' => 'social-custom-icon-'.$loop,
'type' => 'icon',
'title' => __('Icon', 'mfn-opts'),
),
'callback' => $callback,
), $class );
$this->form_row( array(
'args' => array(
'id' => 'social-custom-link-'.$loop,
'type' => 'text',
'title' => __('Link', 'mfn-opts'),
),
'callback' => $callback,
), $class );
$this->form_row( array(
'args' => array(
'id' => 'social-custom-title-'.$loop,
'type' => 'text',
'title' => __( 'Title', 'mfn-opts' ),
),
'callback' => $callback,
), $class );
$this->card_close();
}
}
/**
* Custom font loader
*/
public function custom_font_loader($field){
$loop = 3;
$custom_amount = intval(mfn_opts_get('font-custom-fields')) + $loop;
$callback = $field['callback'];
$class = '';
for( $loop; $loop < $custom_amount; $loop++ ){
$this->card_open( __('Font '.$loop, 'mfn-opts'), array(
'args' => 'Font '.$loop,
'join' => true,
) );
$this->form_row( array(
'args' => array(
'id' => 'font-custom'.$loop,
'type' => 'text',
'title' => __('Name', 'mfn-opts'),
'desc' => __( 'Name for Custom Font uploaded below.
Font will show on fonts list after click the Save Changes button.' , 'mfn-opts' ),
),
'callback' => $callback,
), $class );
$this->form_row( array(
'args' => array(
'id' => 'font-custom'.$loop.'-woff',
'type' => 'upload',
'title' => __('.woff', 'mfn-opts'),
'desc' => __( 'WordPress 5.0 blocks .woff upload. Please use Disable Real MIME Check plugin.', 'mfn-opts' ),
'data' => 'font',
),
'callback' => $callback,
), $class );
$this->form_row( array(
'args' => array(
'id' => 'font-custom'.$loop.'-ttf',
'type' => 'upload',
'title' => __( '.ttf', 'mfn-opts' ),
'desc' => __( 'WordPress 5.0 blocks .ttf upload. Please use Disable Real MIME Check plugin.', 'mfn-opts' ),
'data' => 'font',
),
'callback' => $callback,
), $class );
$this->card_close();
}
}
}
}