'; } /** * Checkbox Callback * * Renders checkboxes. * * @param array $args Arguments passed by the setting */ public static function checkbox( $args ) { $checked = isset( static::$_options[ $args['id'] ] ) ? checked( 1, static::$_options[ $args['id'] ], false ) : ''; $html = ''; $html .= ''; echo $html; } /** * Multicheck Callback * * Renders multiple checkboxes. * * @param array $args Arguments passed by the setting */ public static function multicheck( $args ) { if ( ! empty( $args['options'] ) ) { foreach ( $args['options'] as $key => $option ): if ( isset( static::$_options[ $args['id'] ][ $key ] ) ) { $enabled = $option; } else { $enabled = null; } echo ' '; echo '
'; endforeach; echo '

' . $args['desc'] . '

'; } } /** * Radio Callback * * Renders radio boxes. * * @param array $args Arguments passed by the setting */ public static function radio( $args ) { foreach ( $args['options'] as $key => $option ) : $checked = false; if ( isset( static::$_options[ $args['id'] ] ) && static::$_options[ $args['id'] ] == $key ) { $checked = true; } elseif ( isset( $args['std'] ) && $args['std'] == $key && ! isset( static::$_options[ $args['id'] ] ) ) { $checked = true; } echo ' '; echo '
'; endforeach; echo '

' . $args['desc'] . '

'; } /** * Text Callback * * Renders text fields. * * @param array $args Arguments passed by the setting */ public static function text( $args ) { if ( isset( static::$_options[ $args['id'] ] ) ) { $value = static::$_options[ $args['id'] ]; } else { $value = isset( $args['std'] ) ? $args['std'] : ''; } $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; $html = ''; $html .= ''; echo $html; } /** * Number Callback * * Renders number fields. * * @param array $args Arguments passed by the setting */ public static function number( $args ) { if ( isset( static::$_options[ $args['id'] ] ) ) { $value = static::$_options[ $args['id'] ]; } else { $value = isset( $args['std'] ) ? $args['std'] : ''; } $max = isset( $args['max'] ) ? $args['max'] : 999999; $min = isset( $args['min'] ) ? $args['min'] : 0; $step = isset( $args['step'] ) ? $args['step'] : 1; $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; $html = ''; $html .= ''; echo $html; } /** * Textarea Callback * * Renders textarea fields. * * @param array $args Arguments passed by the setting */ public static function textarea( $args ) { if ( isset( static::$_options[ $args['id'] ] ) ) { $value = static::$_options[ $args['id'] ]; } else { $value = isset( $args['std'] ) ? $args['std'] : ''; } $html = ''; $html .= ''; echo $html; } /** * Password Callback * * Renders password fields. * * @param array $args Arguments passed by the setting */ public static function password( $args ) { if ( isset( static::$_options[ $args['id'] ] ) ) { $value = static::$_options[ $args['id'] ]; } else { $value = isset( $args['std'] ) ? $args['std'] : ''; } $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; $html = ''; $html .= ''; echo $html; } /** * Missing Callback * * If a function is missing for settings callbacks alert the user. * * @param array $args Arguments passed by the setting * * @return void */ public static function missing( $args ) { printf( __( 'The callback function used for the %s setting is missing.', 'content-control' ), $args['id'] ); } /** * Select Callback * * Renders select fields. * * @param array $args Arguments passed by the setting */ public static function select( $args ) { if ( isset( static::$_options[ $args['id'] ] ) ) { $value = static::$_options[ $args['id'] ]; } else { $value = isset( $args['std'] ) ? $args['std'] : ''; } if ( isset( $args['placeholder'] ) ) { $placeholder = $args['placeholder']; } else { $placeholder = ''; } if ( isset( $args['chosen'] ) ) { $chosen = 'class="'. static::$_prefix . '-chosen"'; } else { $chosen = ''; } $html = ''; $html .= ''; echo $html; } /** * Dashicon Callback * * Renders select fields with dashicon preview. * * @param array $args Arguments passed by the setting */ public static function dashicon( $args ) { if ( isset( static::$_options[ $args['id'] ] ) ) { $value = static::$_options[ $args['id'] ]; } else { $value = isset( $args['std'] ) ? $args['std'] : ''; } $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; $html = '
'; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= '
'; echo $html; } /** * Color select Callback * * Renders color select fields. * * @param array $args Arguments passed by the setting */ public static function color_select( $args ) { if ( isset( static::$_options[ $args['id'] ] ) ) { $value = static::$_options[ $args['id'] ]; } else { $value = isset( $args['std'] ) ? $args['std'] : ''; } $html = ''; $html .= ''; echo $html; } /** * Rich Editor Callback * * Renders rich editor fields. * * @param array $args Arguments passed by the setting * * @global $wp_version WordPress Version */ public static function rich_editor( $args ) { global $wp_version; if ( isset( static::$_options[ $args['id'] ] ) ) { $value = static::$_options[ $args['id'] ]; if ( empty( $args['allow_blank'] ) && empty( $value ) ) { $value = isset( $args['std'] ) ? $args['std'] : ''; } } else { $value = isset( $args['std'] ) ? $args['std'] : ''; } $rows = isset( $args['size'] ) ? $args['size'] : 20; if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { ob_start(); wp_editor( stripslashes( $value ), static::$_prefix . 'settings_' . $args['id'], array( 'textarea_name' => static::$_prefix . 'settings[' . $args['id'] . ']', 'textarea_rows' => $rows, ) ); $html = ob_get_clean(); } else { $html = ''; } $html .= '
'; echo $html; } /** * Upload Callback * * Renders upload fields. * * @param array $args Arguments passed by the setting */ public static function upload( $args ) { if ( isset( static::$_options[ $args['id'] ] ) ) { $value = static::$_options[ $args['id'] ]; } else { $value = isset( $args['std'] ) ? $args['std'] : ''; } $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; $html = ''; $html .= ' '; $html .= ''; echo $html; } /** * Color picker Callback * * Renders color picker fields. * * @param array $args Arguments passed by the setting */ public static function color( $args ) { if ( isset( static::$_options[ $args['id'] ] ) ) { $value = static::$_options[ $args['id'] ]; } else { $value = isset( $args['std'] ) ? $args['std'] : ''; } $default = isset( $args['std'] ) ? $args['std'] : ''; $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; $html = ''; $html .= ''; echo $html; } /** * Descriptive text callback. * * Renders descriptive text onto the settings field. * * @param array $args Arguments passed by the setting * * @return void */ public static function descriptive_text( $args ) { echo wp_kses_post( $args['desc'] ); } /** * Registers the license field callback for Software Licensing * * @param array $args Arguments passed by the setting */ public static function license_key( $args ) { if ( isset( static::$_options[ $args['id'] ] ) ) { $value = static::$_options[ $args['id'] ]; } else { $value = isset( $args['std'] ) ? $args['std'] : ''; } $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; $html = ''; if ( 'valid' == get_option( $args['options']['is_valid_license_option'] ) ) { $html .= ''; } $html .= ''; wp_nonce_field( $args['id'] . '-nonce', $args['id'] . '-nonce' ); echo $html; } /** * Hook Callback * * Adds a do_action() hook in place of the field * * @param array $args Arguments passed by the setting * * @return void */ public static function hook( $args ) { do_action( static::$_prefix . $args['id'], $args ); } }