CTprefix . $id . '" value="' . esc_attr( $color ) . '" data-default-color="' . esc_attr( $color ) . '" class="color-picker" />';
} //alanah_colorpicker
/**
* Background color select ( Hex, Transparent & inherit by theme default )
*/
public function alanah_add_background_color_setting( $id ) {
$color = ( alanah_get_option( $id.'_hex' ) && alanah_get_option( $id.'_hex') !== '#' ) ? alanah_get_option( $id.'_hex' ) : '#';
return '
';
} //alanah_add_background_color_setting
/**
* Get image from url and show in admin interface
*/
public function alanah_uploader( $id, $title = '' ) {
$title = $title ? $title : __( 'Upload Image', 'alanah-free' );
$output = '';
$field = $this->CTprefix;
$formid = $field . $id;
$saved_file = alanah_get_option( $id, $field );
$uploadclass = ( $saved_file ) ? 'has-file' : '';
$output .= '
';
if ( $saved_file != '' ) {
$remove = '
';
$image = preg_match( '/(^.*\.jpg|jpeg|png|gif|ico*)/i', $saved_file );
if ( $image ) {
$output .= '

'.$remove.'';
} else {
$parts = explode( "/", $saved_file );
for( $i = 0; $i < sizeof( $parts ); ++$i ) {
$title = $parts[$i];
}
$output .= '
';
}
}
$output .= '
';
$output .= '';
$output .= '';
return $output;
} //alanah_uploader
/**
* Upload hover image in single product page
*/
public function alanah_add_upload_product_setting( $page_id, $id, $title ) {
$title = $title ? $title : __( 'Upload Image', 'alanah-free' );
$output = '';
$formid = $id;
$saved_file = alanah_get_custom_field( '_' . $id );
$uploadclass = ( $saved_file ) ? 'has-file' : '';
$output .= ''.$title.'
';
$output .= '';
if ( $saved_file != '' )
{
$remove = '
';
$image = preg_match( '/(^.*\.jpg|jpeg|png|gif|ico*)/i', $saved_file );
if ( $image )
{
$output .= '

'.$remove.'';
}
else
{
$parts = explode( "/", $saved_file );
for( $i = 0; $i < sizeof($parts); ++$i )
{
$title = $parts[$i];
}
$output .= '
';
}
}
$output .= '
';
$output .= '';
$output .= '';
return $output;
} //alanah_add_upload_product_setting
/**
* Google fonts list from API
*/
public function alanah_grab_gfonts() {
if( ini_get( 'allow_url_fopen' ) && function_exists( 'alanah_parse_json' ) ) :
$fontstr = alanah_parse_json( ALANAH_THEME_DIR . '/assets/fonts/fonts.json' );
$fonts_list = json_decode( $fontstr, true );
else :
if( function_exists( 'alanah_parse_external_file' ) ) {
$fonts_list = alanah_parse_external_file( $this->google_api_key );
}
endif;
return $fonts_list;
}
/**
* Google fonts dropdown
*/
public function alanah_gfonts_dropdown( $default = '' ) {
$fonts = $this->alanah_grab_gfonts();
$options = '';
foreach( $fonts['items'] as $font ) {
//No use wordpress default selected here to prevent unwanted echo
$s = ( $font['family'] == $default ) ? 'selected' : '';
$options .= '';
}
return $options;
}
/**
* Google fonts style dropdown
*/
public function alanah_gfonts_style_dropdown( $currentfont = 'ABeeZee', $default = '' ) {
$fonts = $this->alanah_grab_gfonts();
$options = '';
foreach( $fonts['items'] as $font ) {
if( $currentfont == $font['family'] ) :
//No use wordpress default selected here to prevent unwanted echo
$s = ( 'italic' == $default ) ? 'selected' : '';
$match = 0;
for( $y=0; $y < count( $font['variants'] ); $y++ ) {
if ( preg_match( '/\b(\w*italic\w*)\b/', $font['variants'][$y] ) ) {
$options .= '';
break;
}
}
endif;
}
return $options;
}
/**
* Google fonts weight dropdown
*/
public function alanah_gfonts_weight_dropdown( $currentfont = 'ABeeZee', $currentstyle = 'normal', $default = '' ) {
$fonts = $this->alanah_grab_gfonts();
$options = '';
foreach( $fonts['items'] as $font ) {
if( $currentfont == $font['family'] ) :
for( $y=0; $y < count( $font['variants'] ); $y++ ) {
if( $currentstyle == 'italic' ) :
$optn = ( preg_match( '/\b(\w*italic\w*)\b/', $font['variants'][$y] ) ) ? $font['variants'][$y] : '';
if( !empty ( trim( $optn ) ) ) :
$optn = ( $optn == 'italic' ) ? '400' : $optn;
$optn = str_replace( 'italic', '', $optn );
endif;
else :
$optn = ( ! preg_match( '/\b(\w*italic\w*)\b/', $font['variants'][$y] ) ) ? $font['variants'][$y] : '';
endif;
if( !empty ( trim( $optn ) ) ) :
//No use wordpress default selected here to prevent unwanted echo
$s = ( $optn == $default ) ? 'selected' : '';
$noregular = ( $optn == 'regular' ) ? '400' : $optn;
$options .= '';
endif;
}
endif;
}
return $options;
}
/**
* Alanah Plugin install and activation script. More comfortable for users
*/
public function alanah_register_required_plugins() {
/*
* Array of plugin arrays. Required keys are name and slug.
* If the source is NOT from the .org repo, then source is also required.
*/
$plugins = array(
// Woocommerce
array(
'name' => 'WooCommerce', // The plugin name.
'slug' => 'woocommerce', // The plugin slug (typically the folder name).
'required' => true
)
);
/*
* Array of configuration settings. Amend each line as needed.
*
* TGMPA will start providing localized text strings soon. If you already have translations of our standard
* strings available, please help us make TGMPA even better by giving us access to these translations or by
* sending in a pull-request with .po file(s) with the translations.
*
* Only uncomment the strings in the config array if you want to customize the strings.
*/
$config = array(
'id' => 'alanah', // Unique ID for hashing notices for multiple instances of TGMPA.
'default_path' => '', // Default absolute path to bundled plugins.
'menu' => 'tgmpa-install-plugins', // Menu slug.
'parent_slug' => 'themes.php', // Parent menu slug.
'capability' => 'edit_theme_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used.
'has_notices' => true, // Show admin notices or not.
'dismissable' => true, // If false, a user cannot dismiss the nag message.
'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
'is_automatic' => false, // Automatically activate plugins after installation or not.
'message' => '', // Message to output right before the plugins table.
);
tgmpa( $plugins, $config );
}
} //class ALANAH_ADMIN_SPECIFICS
endif;