field_type_label( $key['name'], $key['_id'] ) . $this->input( $attr, $key ); } /** * Create the Field Text * * @access public * @param array $key The key of field's array to create the HTML field. * @param string $out The HTML form output. * @return string Return the HTML Field Text */ public function field_type_hidden( array $key, $out = '' ) { $attr = array( 'type' => 'hidden', 'desc' => '', ); return $this->field_type_label( $key['name'], $key['_id'] ) . $this->input( $attr, $key ); } /** * Create the field number * * @access public * @param array $key The key of field's array to create the HTML field. * @param string $out The HTML form output. * @return string Return the HTML field number */ public function field_type_number( array $key, $out = '' ) { $attr = array( 'type' => 'number', ); return $this->field_type_label( $key['name'], $key['_id'] ) . $this->input( $attr, $key ); } /** * Create the field email * * @access public * @param array $key The key of field's array to create the HTML field. * @param string $out The HTML form output. * @return string Return the HTML field email */ public function field_type_email( array $key, $out = '' ) { $attr = array( 'type' => 'email', ); return $this->field_type_label( $key['name'], $key['_id'] ) . $this->input( $attr, $key ); } /** * Create the field url * * @access public * @param array $key The key of field's array to create the HTML field. * @param string $out The HTML form output. * @return string Return the HTML field url */ public function field_type_url( array $key, $out = '' ) { $attr = array( 'type' => 'url', ); return $this->field_type_label( $key['name'], $key['_id'] ) . $this->input( $attr, $key ); } /** * Create the field tel * * @access public * @param array $key The key of field's array to create the HTML field. * @param string $out The HTML form output. * @return string Return the HTML field tel */ public function field_type_tel( array $key, $out = '' ) { $attr = array( 'type' => 'tel', ); return $this->field_type_label( $key['name'], $key['_id'] ) . $this->input( $attr, $key ); } /** * Create the field file * * @access public * @param array $key The key of field's array to create the HTML field. * @param string $out The HTML form output. * @return string Return the HTML field file */ public function field_type_file( array $key, $out = '' ) { $attr = array( 'type' => 'file', ); return $this->field_type_label( $key['name'], $key['_id'] ) . $this->input( $attr, $key ); } /** * Create the Field Media * This field add a single image * * @access public * @param array $key The key of field's array to create the HTML field. * @param string $out The HTML form output. * @return string Return the HTML Field Text */ public function field_type_media( array $key, $out = '' ) { $attr = array( 'type' => 'text', ); $out = $this->field_type_label( $key['name'], $key['_id'] ) . $this->input( $attr, $key ); $value = isset( $key['value'] ) ? esc_attr( $key['value'] ) : ''; ob_start(); ?>


'text', ); $out = $this->field_type_label( $key['name'], $key['_id'] ) . $this->input( $attr, $key ); $value = isset( $key['value'] ) ? esc_attr( $key['value'] ) : ''; ob_start(); ?>


'text', ); $out = $this->field_type_label( $key['name'], $key['_id'] ) . $this->input( $attr, $key ); $value = isset( $key['value'] ) ? esc_attr( $key['value'] ) : ''; ob_start(); ?>


field_type_label( $key['name'], $key['_id'] ); $out .= ''; if ( isset( $key['desc'] ) ) { $out .= $this->field_type_description( $key['desc'] ); } return $out; } /** * Create the Field Checkbox * * @access public * @param array $key The key of field's array to create the HTML field. * @param string $out The HTML form output. * @return string Return the HTML Field Checkbox */ public function field_type_checkbox( array $key, $out = '' ) { $out .= ' field_type_label( $key['name'], $key['_id'], false ); if ( isset( $key['desc'] ) ) { $out .= $this->field_type_description( $key['desc'] ); } return $out; } /** * Create the Field Select * * @access public * @param array $key The key of field's array to create the HTML field. * @param string $out The HTML form output. * @return string Return the HTML Field Select */ public function field_type_select( array $key, $out = '' ) { $out .= $this->field_type_label( $key['name'], $key['_id'] ); $out .= ' '; if ( isset( $key['desc'] ) ) { $out .= $this->field_type_description( $key['desc'] ); } return $out; } /** * Create the Field Multiple Select * * @access public * @param array $key The key of field's array to create the HTML field. * @param string $out The HTML form output. * @return string Return the HTML Field Select */ public function field_type_multiple_select( array $key, $out = '' ) { $out .= $this->field_type_label( $key['name'], $key['_id'] ); // $out .= ' '; if ( isset( $key['desc'] ) ) { $out .= $this->field_type_description( $key['desc'] ); } return $out; } /** * Create the Field Multiple Select * * @access public * @param array $key The key of field's array to create the HTML field. * @param string $out The HTML form output. * @return string Return the HTML Field Select */ public function field_type_taxonomy_multiple_select( array $key, $out = '' ) { $out .= $this->field_type_label( $key['name'], $key['_id'] ); $out .= ' '; if ( isset( $key['desc'] ) ) { $out .= $this->field_type_description( $key['desc'] ); } return $out; } /** * Create the Field Select with Options Group * * @access public * @param array $key The key of field's array to create the HTML field. * @param string $out The HTML form output. * @return string Return the HTML Field Select with Options Group */ public function field_type_select_group( array $key, $out = '' ) { $out .= $this->field_type_label( $key['name'], $key['_id'] ); $out .= ''; if ( isset( $key['desc'] ) ) { $out .= $this->field_type_description( $key['desc'] ); } return $out; } /** * Create the Field Editor * * @access public * @param array $key The key of field's array to create the HTML field. * @param string $out The HTML form output. * @return string Return the HTML Field Editor */ public function field_type_editor( array $key, $out = '' ) { $attr = array(); ob_start(); wp_editor( $key['value'], $key['_id'], array( 'textarea_name' => $key['_name'], // 'media_buttons' => false, // 'textarea_rows' => 5, // 'editor_css' => '', 'teeny' => true ) ); $output = ob_get_contents(); ob_end_clean(); return $this->field_type_label( $key['name'], $key['_id'] ) . $output; } /** * Create the field image_size * * @access public * @param array $key The key of field's array to create the HTML field. * @param string $out The HTML form output. * * @return string Return the HTML field image_size */ public function field_type_group( array $key, $out = '' ) { foreach ( $key['group_field'] as $field ) { $this->set_attr_id_name( $field ); /** * Prefix method * * @var string */ $field_method = 'field_type_' . str_replace( '-', '_', $field['type'] ); $attr['type'] = $field['type']; // $out .= method_exists( $this, $field_method ) ? $this->$field_method( $field ) : $this->field_type_text( $field ); $out .= method_exists( $this, $field_method ) ? $this->$field_method( $field ) : $this->field_type_text( $field ); } return sprintf( '%1$s %2$s', $this->field_type_label( $key['name'], $key['_id'] ), $out ); } /** * Create the field description * * @access public * @param string $desc The description. * * @return string Return the description */ public function field_type_description( $desc ) { if ( empty( $desc ) ) { return ''; } return sprintf( '
%s', wp_kses_post( $desc ) ); } /** * Create the field label * * @access public * @param string $name The labels name. * @param string $id The labels ID. * * @return string Return the labels */ public function field_type_label( $name = '', $id = '', $br = true ) { if ( empty( $name ) ) { return ''; } return sprintf( '%s', esc_attr( $id ), esc_html( $name ), $br ? '
' : '' ); } /** * Upload the Javascripts for the media uploader in widget config * * @todo Sistemare gli script da caricare per i vari widget nel pannello admin * * @param string $hook The name of the page. */ public function upload_scripts( $hook ) { if ( 'widgets.php' !== $hook ) { return; } if ( function_exists( 'wp_enqueue_media' ) ) { wp_enqueue_media(); } else { if ( ! wp_script_is( 'thickbox', 'enqueued' ) ) { wp_enqueue_style( 'thickbox' ); wp_enqueue_script( 'thickbox' ); } if ( ! wp_script_is( 'media-upload', 'enqueued' ) ) { wp_enqueue_script( 'media-upload' ); } } wp_enqueue_script( 'jquery-ui-sortable' ); $js_file = ( WP_DEBUG ) ? 'admin/js/src/widget.js' : 'admin/js/widget.min.js'; if ( ! wp_script_is( 'italystrap-widget' ) ) { wp_enqueue_style( 'italystrap-widget', ITALYSTRAP_PLUGIN_URL . 'admin/css/widget.css' ); wp_enqueue_script( 'italystrap-widget', ITALYSTRAP_PLUGIN_URL . $js_file, array( 'jquery', 'jquery-ui-sortable' ) ); } } }