';
$tabs = afcStrings::getString( 'manageSelectors' );
echo '
' . __( 'Advanced Font Changer', 'afc_textdomain' ) . ' ';
settings_errors('afc_addnewselectorsettings');
echo '';
$current = 'afc_addnewselector';
foreach( $tabs as $tab => $name ){
$classnames = ( $tab == $current ) ? ' nav-tab-active' : '';
echo "$name ";
}
echo ' ';
?>
>No
>Yes
getCols( array('name') );
echo '';
echo ' ';
foreach( $allFonts as $font )
if( !$isEmpty && isset($option['properties']['fontName']) && $option['properties']['fontName']['name'] == $font['name'] )
echo '' . $font['name'] . ' ';
else
echo '' . $font['name'] . ' ';
echo ' ';
}
/**
* Prints a select for user to select if plugin must forcefully changes font family of selector or not
*/
function afc_add_forcechange_select_render( ) {
$option = get_option('afc_selector_for_add');
$isEmpty = (is_array($option))? false: true;
?>
>No
>Yes
' . $item . '';
}
?>
' . $item . '';
}
?>
to receive textdecoration
*/
function afc_add_textdecoration_input_render( ) {
$option = get_option('afc_selector_for_add');
$isEmpty = (is_array($option))? false: true;
$items = afcStrings::getString('decorations');
$selected = 'selected="selected"';
?>
' . $item . '';
}
?>
'. __( 'If you dont want text shadow just left all fields blank.', 'afc_textdomain' ) . '
';
}
/**
* Prints available page types for user to choose if we must load the font every where or only in specified page types
*/
function afc_add_pagetype_checkbox_render( ) {
$option = get_option('afc_selector_for_add');
$isEmpty = (is_array($option))? false: true;
$specificTypes = array( 'home', 'archive' );
echo ''. __( 'If the selector is not for specific Page Types don\'t check anyone. For finding id\'s take a look at this link . Seperate each id with a "," character.', 'afc_textdomain' ) . '
Note1: If you have another selector with same name as this one and one of page types of that one match with current selector, plugin removes the existing and adds this one. So be careful when adding a selector that has selector name same as existing one.', 'afc_textdomain' );
}
/**
* Checks values intered in Add Selector page
*/
function afc_validate_newselector( $input ){
$message = '';
$data= array();
$sName = '';
if( !isset( $input['selectorname'] ) || trim( $input['selectorname'] ) == '' )
$message .= __( 'Please fill in selectorname.', 'afc_textdomain' ) . ' ';
else{
$sName = trim( $input['selectorname'] );
if( preg_match( "/[,]/" , $sName ) || preg_match( "/[#.,]$/" , $sName ) ){
$message .= __( 'Selector Name must starts with tag name, id or class name. Also using [,] at the selector name or using [.], [#] at the end of selector name is not allowed. ', 'afc_textdomain' ) . ' ';
}
else{
$data['selectorName'] = $sName;
if( !isset( $input['isshortcode'] ) || trim( $input['isshortcode'] ) == '' )
$message .= __( 'You can not left "is it a short code" field empty.', 'afc_textdomain' ) . ' ';
elseif( $input['isshortcode'] == '1' && preg_match( "/^.+[.# ]/" , $sName ) ){
$message .= __( "For using this selector in a shortcode it might not have '.' , '#' or ' '(space) in the middle or end of its name. But using [.] or [#] in the begin is allowed. ", 'afc_textdomain' ) . ' ';
}
elseif( $input['isshortcode'] == '1' ){
$data['editorData']['isShortCode'] = 1;
}
else{
$data['editorData']['isShortCode'] = 0;
}
if( isset( $data['editorData']['isShortCode'] ) && $data['editorData']['isShortCode'] == 1
&& !preg_match( "/^[.#].*/", $sName ) ){
$data['selectorName'] = '.' . $sName;
}
}
}
if( isset( $input['fontname'] ) && $input['fontname'] != '' && $input['fontname'] != 'none' ){
$afcFonts = new afcfonts();
$fontExists = $afcFonts->getFonts( 'name', array( $input['fontname'] ) );
if( count( $fontExists ) <= 0 ){
$message .= __( 'Selected Font for this selector is invalid.', 'afc_textdomain' ). ' ';
}
else{
$data['properties']['fontName']['name'] = trim( $input['fontname'] );
}
}
if( $input['fontname'] == 'none' && $input['forcechange'] == '1' )
$message .= __( 'You have not selected any font to force it.', 'afc_textdomain' ) . ' ';
if( isset( $data['properties']['fontName'] ) )
$data['properties']['fontName']['forceChangeFont'] = trim( $input['forcechange'] );
if( isset( $input['fontsize'] ) && $input['fontsize'] != '' ){
if( !ctype_digit( trim( $input['fontsize'] ) ) ){
$message .= __( 'Fontsize is numeric, please type a positive number or left it empty.', 'afc_textdomain' ) . ' ';
}
else{
$data['properties']['fontSize'] = trim( $input['fontsize'] );
}
}
if( isset( $input['fontweight'] ) && $input['fontweight'] != '' && $input['fontweight'] != 'none' ){
if( !ctype_digit( $input['fontweight'] ) ){
$message .= __( 'Font Weight is numeric.', 'afc_textdomain' ) . ' ';
}
else{
$data['properties']['fontWeight'] = trim( $input['fontweight'] );
}
}
if( isset( $input['fontstyle'] ) && $input['fontstyle'] != '' && $input['fontstyle'] != 'none' ){
if( !in_array( $input['fontstyle'], afcStrings::getString('fontstyles') ) ){
$message .= __( 'Invalid font style.', 'afc_textdomain' ) . ' ';
}
else{
$data['properties']['fontStyle'] = trim( $input['fontstyle'] );
}
}
if( isset( $input['textcolor'] ) && $input['textcolor'] != '' ){
if( !preg_match( "/^[#][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]$/i", $input['textcolor'] ) )
$message .= __( 'The text color code is invalid.', 'afc_textdomain' ) . ' ';
else{
$data['properties']['textColor'] = trim( $input['textcolor'] );
}
}
if( isset( $input['textdecoration'] ) && $input['textdecoration'] != '' && $input['textdecoration'] != 'none' ){
if( !in_array( $input['textdecoration'], afcStrings::getString('decorations') ) ){
$message .= __( 'Selected decoration is invalid.', 'afc_textdomain' ) . ' ';
}
else{
$data['properties']['textDecoration'] = trim( $input['textdecoration'] );
}
}
if( isset( $input['textshadow'] ) ){
if( $input['textshadow']['h-shadow'] != '' && $input['textshadow']['v-shadow'] != '' ){
if( !preg_match( "/^[-]*[0-9]+$/", $input['textshadow']['h-shadow'] ) || !preg_match( "/^[-]*[0-9]+$/", $input['textshadow']['v-shadow'] ) ){
$message .= __( 'Horizontal or vertical values in text shadow fields are invalid.', 'afc_textdomain' ) . ' ';
}
else{
$data['properties']['textShadow']['hshadow'] = trim( $input['textshadow']['h-shadow'] );
$data['properties']['textShadow']['vshadow'] = trim( $input['textshadow']['v-shadow'] );
if( $input['textshadow']['blur'] != '' ){
if( !preg_match( "/^[-]*[0-9]+$/", $input['textshadow']['blur'] ) ){
$message .= __( 'Value in blur field of text shadow is invalid.', 'afc_textdomain' ) . ' ';
}
else{
$data['properties']['textShadow']['blur'] = trim( $input['textshadow']['blur'] );
}
}
if( $input['textshadow']['color'] != '' ){
if( !preg_match( "/^[#][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]$/i", $input['textshadow']['color'] ) )
$message .= __( 'Text shadow color code is invalid.', 'afc_textdomain' ) . ' ';
else{
$data['properties']['textShadow']['color'] = trim( $input['textshadow']['color'] );
}
}
}
}
elseif( ( $input['textshadow']['h-shadow'] == '' && $input['textshadow']['v-shadow'] != '' )
|| ( $input['textshadow']['h-shadow'] != '' && $input['textshadow']['v-shadow'] == '' ) ){
$message .= __( 'Both the h-shadow and v-shadow of textshadow are required, left them empty or fill in both.', 'afc_textdomain' ) . ' ';
}
}
$specificTypes = array( 'home', 'archive' );
if( isset( $input['pagetype'] ) ){
foreach ( afcStrings::getString('pagetype') as $pt=>$val ){
if( isset( $input['pagetype'][ $pt ]['checked'] ) ){
if( isset( $input['pagetype'][ $pt ]['valuearr'] ) && $input['pagetype'][ $pt ]['valuearr'] != '' && !in_array( $pt, $specificTypes ) ){
if( !preg_match( "/^([0-9]+[,]*)*[0-9]+$/", $input['pagetype'][ $pt ]['valuearr'] ) )
$message .= __( 'Intered value in following field is incorrect:', 'afc_textdomain' ) . $val . __( ' . example of correct value is: 1,2,3', 'afc_textdomain' ) . ' ';
else{
$data['pageType'][ $pt ]['status'] = $input['pagetype'][ $pt ]['status'];
$data['pageType'][ $pt ]['valueArr'] = explode( ',', trim( $input['pagetype'][ $pt ]['valuearr'] ) );
}
}
else{
$data['pageType'][ $pt ] = 'empty';
}
}
}
}
if( !isset( $data['properties'] ) )
$data['properties'] = array();
if( !isset( $data['pageType'] ) || count( $data['pageType'] ) <= 0 )
$data['pageType']['all'] = 'empty';
$afcselectors = new afcselectors();
if( $message == '' ){
$data['id'] = 'null';
$explodedSelector = explode( ' ', $data['selectorName'] );
$parents = -1;
foreach( $explodedSelector as $parent){
if( trim( $parent ) != '' )
$parents++;
}
$data['editorData']['numOfParents'] = $parents;
$data['editorData']['isEditable'] = 0;
$data['editorData']['isNew'] = 1;
$result = $afcselectors->getSimilarSelectors( $data );
if( count( $result ) >= 1 ){
$check = $afcselectors->isEqualSelectors( $data, $result );
if( $check )
$message = $check;
}
}
if( $message == '' ){
update_option('afc_selector_for_add', '');
$afcselectors->addelems( array( $data ) );
$type = 'updated';
$message = __( 'New selector successfully saved.', 'afc_textdomain' );
}
else{
$type = 'error';
}
if($message != '')
update_option('afc_selector_for_add', $data);
add_settings_error( 'afc_addnewselectorsettings', 'afc', $message, $type );
}
?>