HTML = ''; $this->JS = ''; $this->type = 'text'; $this->plainHTML = false; $this->useParagraph = true; $this->helpText = ''; $this->id = ''; $this->name = ''; $this->value = ''; $this->label = ''; $this->className = 'input widefat'; $this->style = ''; $this->required = ''; $this->options = null; $this->optionName = ''; $this->optionIdentifier = ''; $this->values = ''; if ( isset( $args ) && is_array( $args ) ) { if ( isset( $args['type'] ) && ( $args['type'] != '' ) ) { $this->type = $args['type']; } if ( isset( $args['plainHTML'] ) && ( $args['plainHTML'] != '' ) ) { $this->plainHTML = $args['plainHTML']; } if ( isset( $args['useParagraph'] ) && ( $args['useParagraph'] != '' ) ) { $this->useParagraph = $args['useParagraph']; } if ( isset( $args['helpText'] ) && ( $args['helpText'] != '' ) ) { $this->helpText = $args['helpText']; } if ( isset( $args['id'] ) && ( $args['id'] != '' ) ) { $this->id = $args['id']; } if ( isset( $args['name'] ) && ( $args['name'] != '' ) ) { $this->name = $args['name']; } if ( isset( $args['value'] ) && ( $args['value'] != '' ) ) { $this->value = $args['value']; } if ( isset( $args['label'] ) && ( $args['label'] != '' ) ) { $this->label = $args['label']; } if ( isset( $args['className'] ) && ( $args['className'] != '' ) ) { $this->className = $args['className']; } if ( isset( $args['style'] ) && ( $args['style'] != '' ) ) { $this->style = $args['style']; } if ( isset( $args['required'] ) && ( $args['required'] != '' ) ) { $this->required = $args['required']; } if ( isset( $args['options'] ) && is_array( $args['options'] ) ) { $this->options = $args['options']; } if ( isset( $args['optionIdentifier'] ) && ( $args['optionIdentifier'] != '' ) ) { $this->optionIdentifier = $args['optionIdentifier']; } if ( isset( $args['optionName'] ) && ( $args['optionName'] != '' ) ) { $this->optionName = $args['optionName']; } if ( isset( $args['values'] ) && ( $args['values'] != '' ) ) { $this->values = $args['values']; } if ( isset( $args['optionIdentifier'] ) && ( $args['optionIdentifier'] != '' ) && isset( $args['optionName'] ) && ( $args['optionName'] != '' ) ) { $this->id = str_replace( [ '[', ']' ], [ '_', '' ], $args['optionIdentifier'] ) . '_' . $args['optionName']; $this->name = $args['optionIdentifier'] . '[' . $args['optionName'] . ']'; } elseif ( isset( $this->optionIdentifier ) && ( $this->optionIdentifier != '' ) && isset( $args['optionName'] ) && ( $args['optionName'] != '' ) ) { $this->id = str_replace( [ '[', ']' ], [ '_', '' ], $this->optionIdentifier ) . '_' . $args['optionName']; $this->name = $this->optionIdentifier . '[' . $args['optionName'] . ']'; } elseif ( isset( $args['optionIdentifier'] ) && ( $args['optionIdentifier'] != '' ) && isset( $this->optionName ) && ( $this->optionName != '' ) ) { $this->id = str_replace( [ '[', ']' ], [ '_', '' ], $args['optionIdentifier'] ) . '_' . $this->optionName; $this->name = $args['optionIdentifier'] . '[' . $this->optionName . ']'; } elseif ( isset( $this->optionIdentifier ) && ( $this->optionIdentifier != '' ) && isset( $this->optionName ) && ( $this->optionName != '' ) ) { $this->id = str_replace( [ '[', ']' ], [ '_', '' ], $this->optionIdentifier ) . '_' . $this->optionName; $this->name = $this->optionIdentifier . '[' . $this->optionName . ']'; } if ( isset( $args['values'] ) && is_array( $args['values'] ) ) { if ( isset( $args['optionName'] ) && ( $args['optionName'] != '' ) ) { $this->value = $args['values'][ $args['optionName'] ]; } elseif ( isset( $this->optionName ) && ( $this->optionName != '' ) ) { $this->value = $args['values'][ $this->optionName ]; } } elseif ( isset( $this->values ) && is_array( $this->values ) ) { if ( isset( $args['optionName'] ) && ( $args['optionName'] != '' ) ) { $this->value = $this->values[ $args['optionName'] ]; } elseif ( isset( $this->optionName ) && ( $this->optionName != '' ) ) { $this->value = $this->values[ $this->optionName ]; } } } } private function sync_args( $args ) { $syncedArgs = []; if ( is_array( $args ) ) { $syncedArgs = $args; } if ( isset( $args['type'] ) && ( $args['type'] != '' ) ) { $syncedArgs['type'] = $args['type']; } else { $syncedArgs['type'] = $this->type; } if ( isset( $args['plainHTML'] ) && is_bool( $args['plainHTML'] ) ) { $syncedArgs['plainHTML'] = $args['plainHTML']; } else { $syncedArgs['plainHTML'] = $this->plainHTML; } if ( isset( $args['useParagraph'] ) && is_bool( $args['useParagraph'] ) ) { $syncedArgs['useParagraph'] = $args['useParagraph']; } else { $syncedArgs['useParagraph'] = $this->useParagraph; } if ( isset( $args['helpText'] ) && ( $args['helpText'] != '' ) ) { $syncedArgs['helpText'] = $args['helpText']; } else { $syncedArgs['helpText'] = $this->helpText; } if ( isset( $args['id'] ) && ( $args['id'] != '' ) ) { $syncedArgs['id'] = $args['id']; } else { $syncedArgs['id'] = $this->id; } if ( isset( $args['name'] ) && ( $args['name'] != '' ) ) { $syncedArgs['name'] = $args['name']; } else { $syncedArgs['name'] = $this->name; } if ( isset( $args['label'] ) && ( $args['label'] != '' ) ) { $syncedArgs['label'] = $args['label']; } else { $syncedArgs['label'] = $this->label; } if ( isset( $args['className'] ) && ( $args['className'] != '' ) ) { $syncedArgs['className'] = $args['className']; } else { $syncedArgs['className'] = $this->className; } if ( isset( $args['style'] ) && ( $args['style'] != '' ) ) { $syncedArgs['style'] = $args['style']; } else { $syncedArgs['style'] = $this->style; } if ( isset( $args['required'] ) && ( $args['required'] != '' ) ) { $syncedArgs['required'] = $args['required']; } else { $syncedArgs['required'] = $this->required; } if ( isset( $args['options'] ) && is_array( $args['options'] ) ) { $syncedArgs['options'] = $args['options']; } else { $syncedArgs['options'] = $this->options; } if ( isset( $args['optionIdentifier'] ) && ( $args['optionIdentifier'] != '' ) && isset( $args['optionName'] ) && ( $args['optionName'] != '' ) ) { $syncedArgs['id'] = str_replace( [ '[', ']' ], [ '_', '' ], $args['optionIdentifier'] ) . '_' . $args['optionName']; $syncedArgs['name'] = $args['optionIdentifier'] . '[' . $args['optionName'] . ']'; } elseif ( isset( $this->optionIdentifier ) && ( $this->optionIdentifier != '' ) && isset( $args['optionName'] ) && ( $args['optionName'] != '' ) ) { $syncedArgs['id'] = str_replace( [ '[', ']' ], [ '_', '' ], $this->optionIdentifier ) . '_' . $args['optionName']; $syncedArgs['name'] = $this->optionIdentifier . '[' . $args['optionName'] . ']'; } elseif ( isset( $args['optionIdentifier'] ) && ( $args['optionIdentifier'] != '' ) && isset( $this->optionName ) && ( $this->optionName != '' ) ) { $syncedArgs['id'] = str_replace( [ '[', ']' ], [ '_', '' ], $args['optionIdentifier'] ) . '_' . $this->optionName; $syncedArgs['name'] = $args['optionIdentifier'] . '[' . $this->optionName . ']'; } elseif ( isset( $this->optionIdentifier ) && ( $this->optionIdentifier != '' ) && isset( $this->optionName ) && ( $this->optionName != '' ) ) { $syncedArgs['id'] = str_replace( [ '[', ']' ], [ '_', '' ], $this->optionIdentifier ) . '_' . $this->optionName; $syncedArgs['name'] = $this->optionIdentifier . '[' . $this->optionName . ']'; } if ( isset( $args['value'] ) && ( $args['value'] != '' ) ) { $syncedArgs['value'] = $args['value']; } elseif ( isset( $args['values'] ) && is_array( $args['values'] ) ) { if ( isset( $args['optionName'] ) && ( $args['optionName'] != '' ) ) { $syncedArgs['value'] = $args['values'][ $args['optionName'] ]; } elseif ( isset( $this->optionName ) && ( $this->optionName != '' ) ) { $syncedArgs['value'] = $args['values'][ $this->optionName ]; } } elseif ( isset( $this->values ) && is_array( $this->values ) ) { if ( isset( $args['optionName'] ) && ( $args['optionName'] != '' ) ) { $syncedArgs['value'] = $this->values[ $args['optionName'] ]; } elseif ( isset( $this->optionName ) && ( $this->optionName != '' ) ) { $syncedArgs['value'] = $this->values[ $this->optionName ]; } } else { $syncedArgs['value'] = $this->value; } return $syncedArgs; } public function add_control( $args = null ) { $control = $this->get_control( $args, true ); $this->HTML .= $control['HTML']; $this->JS .= $control['JS']; } public function get_control( $args = null, $ignorePlainHTML = false ) { $HTML = ''; $JS = ''; $args = $this->sync_args( $args ); switch ( $args['type'] ) { case 'hidden': $HTML .= ''; break; case 'text': if ( $args['useParagraph'] ) { $HTML .= '
'; }
if ( $args['label'] != '' ) {
$HTML .= '
'; }
$HTML .= '';
if ( $args['helpText'] != '' ) {
$HTML .= '' . $args['helpText'] . ''; }
if ( $args['useParagraph'] ) {
$HTML .= '
'; }
if ( $args['label'] != '' ) {
$HTML .= '
'; }
$HTML .= '';
if ( $args['helpText'] != '' ) {
$HTML .= '' . $args['helpText'] . ''; }
if ( $args['useParagraph'] ) {
$HTML .= '
'; }
if ( $args['label'] != '' ) {
$HTML .= '
'; }
$HTML .= '';
if ( $args['helpText'] != '' ) {
$HTML .= '' . $args['helpText'] . ''; }
if ( $args['useParagraph'] ) {
$HTML .= '
'; }
if ( $args['label'] != '' ) {
$HTML .= '
'; }
$HTML .= '';
if ( $args['helpText'] != '' ) {
$HTML .= '' . $args['helpText'] . ''; }
if ( $args['useParagraph'] ) {
$HTML .= '
'; } if ( isset( $args['value'] ) && ( filter_var( $args['value'], FILTER_VALIDATE_BOOLEAN ) ) ) { $HTML .= ''; } else { $HTML .= ''; } if ( $args['label'] != '' ) { $HTML .= ' '; } if ( $args['helpText'] != '' ) { $HTML .= '' . $args['helpText'] . ''; } if ( $args['useParagraph'] ) { $HTML .= '
'; } break; case 'radio': if ( $args['useParagraph'] ) { $HTML .= ''; } if ( isset( $args['value'] ) && ( filter_var( $args['value'], FILTER_VALIDATE_BOOLEAN ) ) ) { $HTML .= ''; } else { $HTML .= ''; } if ( $args['label'] != '' ) { $HTML .= ' '; } if ( $args['helpText'] != '' ) { $HTML .= '' . $args['helpText'] . ''; } if ( $args['useParagraph'] ) { $HTML .= '
'; } break; case 'select': if ( $args['useParagraph'] ) { $HTML .= ''; }
if ( $args['label'] != '' ) {
$HTML .= '
'; }
$HTML .= '';
if ( $args['helpText'] != '' ) {
$HTML .= '' . $args['helpText'] . ''; }
if ( $args['useParagraph'] ) {
$HTML .= '
'; }
if ( $args['label'] != '' ) {
$HTML .= '
'; }
$HTML .= '';
if ( $args['helpText'] != '' ) {
$HTML .= '' . $args['helpText'] . ''; }
if ( $args['useParagraph'] ) {
$HTML .= '
'; }
if ( $args['label'] != '' ) {
$HTML .= '
'; }
if ( is_array( $args['options'] ) ) {
$index = 1;
foreach ( $args['options'] as $option ) {
$HTML .= '';
if ( $option['text'] != '' ) {
$HTML .= '
'; }
++$index;
}
}
if ( $args['helpText'] != '' ) {
$HTML .= '' . $args['helpText'] . ''; }
if ( $args['useParagraph'] ) {
$HTML .= '
'; } if ( isset( $args['value'] ) && ( filter_var( $args['value'], FILTER_VALIDATE_BOOLEAN ) ) ) { $HTML .= ''; } else { $HTML .= ''; } if ( $args['label'] != '' ) { $HTML .= ' '; } if ( $args['helpText'] != '' ) { $HTML .= '' . $args['helpText'] . ''; } if ( $args['useParagraph'] ) { $HTML .= '
'; } $JS .= 'jQuery("#' . ( ( $args['id'] != '' ) ? $args['id'] : '' ) . '").ipCheckbox();'; break; case 'minicolors': if ( $args['useParagraph'] ) { $HTML .= ''; }
if ( $args['label'] != '' ) {
$HTML .= '
'; }
$HTML .= '';
if ( $args['helpText'] != '' ) {
$HTML .= '' . $args['helpText'] . ''; }
if ( $args['useParagraph'] ) {
$HTML .= '
'; }
if ( $args['label'] != '' ) {
$HTML .= '
'; }
$HTML .= '';
if ( $args['helpText'] != '' ) {
$HTML .= '' . $args['helpText'] . ''; }
if ( $args['useParagraph'] ) {
$HTML .= '
'; } if ( isset( $args['value'] ) && ( filter_var( $args['value'], FILTER_VALIDATE_BOOLEAN ) ) ) { $HTML .= ''; } else { $HTML .= ''; } if ( $args['label'] != '' ) { $HTML .= ''; } if ( $args['helpText'] != '' ) { $HTML .= '' . $args['helpText'] . ''; } if ( $args['useParagraph'] ) { $HTML .= '
'; } $JS .= 'jQuery("#' . ( ( $args['id'] != '' ) ? $args['id'] : '' ) . '").button({ create: function(event, ui) { jQuery(this).button("option", "label", (jQuery(this).is(":checked")?"' . ( ( $args['checkedLabel'] != '' ) ? $args['checkedLabel'] : '' ) . '":"' . ( ( $args['uncheckedLabel'] != '' ) ? $args['uncheckedLabel'] : '' ) . '")) }}).change(function () { jQuery(this).button("option", "label", (jQuery(this).is(":checked")?"' . ( ( $args['checkedLabel'] != '' ) ? $args['checkedLabel'] : '' ) . '":"' . ( ( $args['uncheckedLabel'] != '' ) ? $args['uncheckedLabel'] : '' ) . '")); });'; break; case 'pages-select': $this->load_data( 'pages' ); if ( $args['useParagraph'] ) { $HTML .= ''; }
if ( $args['label'] != '' ) {
$HTML .= '
'; }
$HTML .= '';
if ( $args['helpText'] != '' ) {
$HTML .= '' . $args['helpText'] . ''; }
if ( $args['useParagraph'] ) {
$HTML .= '
'; }
if ( $args['label'] != '' ) {
$HTML .= '
'; }
$HTML .= '';
if ( $args['helpText'] != '' ) {
$HTML .= '' . $args['helpText'] . ''; }
if ( $args['useParagraph'] ) {
$HTML .= '
'; }
if ( $args['label'] != '' ) {
$HTML .= '
'; }
$HTML .= '';
if ( $args['helpText'] != '' ) {
$HTML .= '' . $args['helpText'] . ''; }
if ( $args['useParagraph'] ) {
$HTML .= '
'; }
if ( $args['label'] != '' ) {
$HTML .= '
'; }
$HTML .= '';
if ( $args['helpText'] != '' ) {
$HTML .= '' . $args['helpText'] . ''; }
if ( $args['useParagraph'] ) {
$HTML .= '
'; }
if ( $args['label'] != '' ) {
$HTML .= '
'; }
$HTML .= '';
if ( $args['helpText'] != '' ) {
$HTML .= '' . $args['helpText'] . ''; }
if ( $args['useParagraph'] ) {
$HTML .= '
'; }
if ( $args['label'] != '' ) {
$HTML .= '
'; }
$HTML .= '';
if ( $args['helpText'] != '' ) {
$HTML .= '' . $args['helpText'] . ''; }
if ( $args['useParagraph'] ) {
$HTML .= '