コード例 #1
0
 /**
  * Collect metadata from all boxes.
  */
 function save_post($post_id, $post)
 {
     if ('revision' == $post->post_type || defined('DOING_AJAX')) {
         return;
     }
     if (isset($_POST['p2p_connections'])) {
         // Loop through the hidden fields instead of through $_POST['p2p_meta'] because empty checkboxes send no data.
         foreach ($_POST['p2p_connections'] as $p2p_id) {
             $data = scbForms::get_value(array('p2p_meta', $p2p_id), $_POST, array());
             $connection = p2p_get_connection($p2p_id);
             if (!$connection) {
                 continue;
             }
             $fields = p2p_type($connection->p2p_type)->fields;
             foreach ($fields as $key => &$field) {
                 $field['name'] = $key;
             }
             $data = scbForms::validate_post_data($fields, $data);
             scbForms::update_meta($fields, $data, $p2p_id, 'p2p');
         }
     }
     // Ordering
     if (isset($_POST['p2p_order'])) {
         foreach ($_POST['p2p_order'] as $key => $list) {
             foreach ($list as $i => $p2p_id) {
                 p2p_update_meta($p2p_id, $key, $i);
             }
         }
     }
 }
コード例 #2
0
 private function wrap_upload($field_name, $desc)
 {
     $upload_button = html('input', array('class' => 'upload_button button', 'rel' => $field_name, 'type' => 'button', 'value' => __('Upload Image', APP_TD)));
     $clear_button = html('input', array('class' => 'delete_button button', 'rel' => $field_name, 'type' => 'button', 'value' => __('Clear Image', APP_TD)));
     $preview = html('div', array('id' => $field_name . '_image', 'class' => 'upload_image_preview'), html('img', array('src' => scbForms::get_value($field_name, $this->options->get()))));
     return $upload_button . ' ' . $clear_button . $desc . $preview;
 }
コード例 #3
0
ファイル: Forms.php プロジェクト: bidhanbaral/fotodep_store
 static function textarea($args, $content = '')
 {
     if (!empty($content)) {
         $args['value'] = $content;
     }
     self::$args = $args;
     return self::_textarea();
 }
コード例 #4
0
 function render($p2p_id, $_)
 {
     $args = $this->data;
     $args['name'] = array('p2p_meta', $p2p_id, $this->key);
     if ('select' == $args['type'] && !isset($args['text'])) {
         $args['text'] = '';
     }
     return scbForms::input_from_meta($args, $p2p_id, 'p2p');
 }
コード例 #5
0
 function settings_handler()
 {
     if (!isset($_POST['save_settings'])) {
         return;
     }
     $to_update = scbForms::validate_post_data($this->settings_fields);
     $this->options->update($to_update);
     $this->admin_msg();
 }
コード例 #6
0
 /**
  *
  * @since 2.0.0
  *
  * @return string
  */
 public function render()
 {
     $parts = array(html('div class="intro-text"', html('h2', __('Get Started with Postmatic', 'Postmatic')), html('p', __('Build relationships, engage your community, and grow your platform using Postmatic.', 'Postmatic'))));
     $parts[] = $this->feature_chooser_html();
     $table_entries = array(array('title' => __('Postmatic Api Key', 'Postmatic'), 'type' => 'text', 'name' => 'prompt_key', 'extra' => array('class' => 'regular-text last-submit')));
     $this->override_entries($table_entries);
     $parts[] = $this->table($table_entries, $this->options->get()) . html('div class="opt-in"', html('div', html('h3', __('Improve your site by making Postmatic even better', 'Postmatic')), html('p', __('We rely on users like you to help shape our development roadmap. By checking the box below you will be helping us know more about your site and how we can make Postmatic even better.', 'Postmatic'))), scbForms::input(array('type' => 'checkbox', 'name' => 'enable_collection', 'desc' => html('strong', __('Yes, send periodic usage statistics to Postmatic.', 'Postmatic'))), $this->options->get()));
     return $this->form_wrap(implode('', $parts));
 }
コード例 #7
0
function appthemes_list_gateway_dropdown($input_name = 'payment_gateway')
{
    $gateways = array();
    foreach (APP_Gateway_Registry::get_gateways() as $gateway) {
        // Skip disabled gateways
        if (!APP_Gateway_registry::is_gateway_enabled($gateway->identifier())) {
            continue;
        }
        $gateways[$gateway->identifier()] = $gateway->display_name('dropdown');
    }
    echo scbForms::input(array('type' => 'select', 'name' => $input_name, 'values' => $gateways, 'extra' => array('class' => 'required')));
}
コード例 #8
0
 protected function render_dropdown()
 {
     $direction = $this->ctype->flip_direction()->get_direction();
     $labels = $this->ctype->get('current', 'labels');
     if (isset($labels->dropdown_title)) {
         $title = $labels->dropdown_title;
     } elseif (isset($labels->column_title)) {
         $title = $labels->column_title;
     } else {
         $title = $this->title;
     }
     return scbForms::input(array('type' => 'select', 'name' => array('p2p', $this->ctype->name, $direction), 'choices' => self::get_choices($this->ctype), 'text' => $title), $_GET);
 }
コード例 #9
0
 static function handle_form()
 {
     if (empty($_POST['action']) || 'manage-escrow' != $_POST['action']) {
         return;
     }
     if (!wp_verify_nonce($_POST['_wpnonce'], 'app-manage-escrow')) {
         return;
     }
     $sanitized_user_meta = scbForms::validate_post_data(self::get_fields());
     foreach ($sanitized_user_meta as $meta_key => $meta_value) {
         update_user_option(get_current_user_id(), $meta_key, $meta_value);
     }
     appthemes_add_notice('saved-escrow-settings', __('Settings Saved.', APP_TD), 'success');
 }
コード例 #10
0
 function form_handler()
 {
     if (empty($_POST['action']) || !isset($this->tabs[$_POST['action']])) {
         return;
     }
     check_admin_referer($this->nonce);
     $form_fields = array();
     foreach ($this->tab_sections[$_POST['action']] as $section) {
         $form_fields = array_merge($form_fields, $section['fields']);
     }
     $to_update = scbForms::validate_post_data($form_fields, $this->options->get());
     $this->options->update($to_update);
     $this->admin_msg();
 }
コード例 #11
0
 function page_content()
 {
     $tags = '';
     foreach (SAR_Core::get_available_tags() as $tag) {
         $tags .= "\n\t" . html('li', html('em', $tag));
     }
     $default_date = __('Default', $this->textdomain) . ': ' . get_option('date_format') . ' ( ' . date_i18n(get_option('date_format')) . ' )';
     $data = array();
     $formdata = $this->options->get();
     $formdata['exclude_cat'] = implode(', ', (array) $formdata['exclude_cat']);
     $data['sections'][] = array('title' => __('General settings', $this->textdomain), 'id' => 'general', 'rows' => scbForms::table(array(array('title' => __('Exclude Categories by ID', $this->textdomain), 'desc' => __('(comma separated)', $this->textdomain), 'type' => 'text', 'name' => 'exclude_cat'), array('title' => __('Format', $this->textdomain), 'type' => 'radio', 'name' => 'format', 'value' => array('block', 'list', 'both', 'fancy'), 'desc' => array(__('block', $this->textdomain), __('list', $this->textdomain), __('both', $this->textdomain), __('fancy', $this->textdomain)))), $formdata));
     $data['sections'][] = array('title' => __('Specific settings', $this->textdomain), 'id' => 'specific', 'rows' => scbForms::table(array(array('title' => __('List format', $this->textdomain), 'desc' => html('p', __('Available substitution tags', $this->textdomain)) . html('ul', $tags), 'type' => 'text', 'name' => 'list_format'), array('title' => sprintf(__('%s format', $this->textdomain), '%date%'), 'desc' => html('p', $default_date) . html('p', html('em', __('See available date formatting characters <a href="http://php.net/date" target="_blank">here</a>.', $this->textdomain))), 'type' => 'text', 'name' => 'date_format'), array('title' => __('Month names', $this->textdomain), 'type' => 'radio', 'name' => 'month_format', 'value' => array('numeric', 'short', 'long'), 'desc' => array(__('numeric', $this->textdomain), __('short', $this->textdomain), __('long', $this->textdomain))), array('title' => __('Use anchor links in block', $this->textdomain), 'desc' => __('The month links in the block will point to the month links in the list', $this->textdomain), 'type' => 'checkbox', 'name' => 'anchors')), $formdata));
     $output = SAR_Core::mustache_render(dirname(__FILE__) . '/admin.html', $data);
     echo $this->form_wrap($output);
 }
コード例 #12
0
ファイル: class-meta-box.php プロジェクト: kalushta/darom
 /**
  * Returns table row.
  *
  * @param array $row
  * @param array $formdata
  * @param array $errors (optional)
  *
  * @return string
  */
 public function table_row($row, $formdata, $errors = array())
 {
     if (empty($row['tip'])) {
         $tip = '';
     } else {
         $tip = html("i", array('class' => 'at at-tip', 'data-tooltip' => APP_ToolTips::supports_wp_pointer() ? $row['tip'] : __('Click for more info', APP_TD)));
         if (!APP_ToolTips::supports_wp_pointer()) {
             $tip .= html("div class='tip-content'", $row['tip']);
         }
     }
     if (isset($row['desc'])) {
         $row['desc'] = html('span class="app-description"', $row['desc']);
     }
     $input = scbForms::input($row, $formdata);
     // If row has an error, highlight it
     $style = in_array($row['name'], $errors) ? 'style= "background-color: #FFCCCC"' : '';
     return html('tr', html("th {$style} scope='row'", html('label for="' . esc_attr($row['title']) . '"', $row['title']) . $tip), html("td {$style}", $input));
 }
コード例 #13
0
ファイル: Forms.php プロジェクト: selectSIFISO/.comsite
 static function input($args, $formdata = array())
 {
     $args = self::validate_data($args);
     $error = false;
     foreach (array('name', 'value') as $key) {
         $old = $key . 's';
         if (isset($args[$old])) {
             $args[$key] = $args[$old];
             unset($args[$old]);
         }
     }
     if (empty($args['name'])) {
         return trigger_error('Empty name', E_USER_WARNING);
     }
     self::$args = $args;
     self::$formdata = self::validate_data($formdata);
     if ('select' == $args['type']) {
         return self::_select();
     } else {
         return self::_input();
     }
 }
コード例 #14
0
ファイル: Widget.php プロジェクト: realfluid/umbaugh
	protected function input( $args, $formdata = array() ) {
		// Add default class
		if ( !isset( $args['extra'] ) )
			$args['extra'] = 'class="regular-text"';

		// Add default label position
		if ( !in_array( $args['type'], array( 'checkbox', 'radio' ) ) && empty( $args['desc_pos'] ) )
			$args['desc_pos'] = 'before';

		// Then add prefix to names and formdata
		$new_formdata = array();
		foreach ( ( array ) $args['name'] as $name )
			$new_formdata[$this->scb_get_field_name( $name )] = @$formdata[$name];
		$new_names = array_keys( $new_formdata );

		// Finally, replace the old names
		if ( 1 == count( $new_names ) )
			$args['name'] = $new_names[0];
		else
			$args['name'] = $new_names;

		return scbForms::input( $args, $new_formdata );
	}
コード例 #15
0
ファイル: Forms.php プロジェクト: kitfrench/Futurestep
 static function input($args, $formdata = array())
 {
     foreach (array('name', 'value') as $key) {
         $old = $key . 's';
         if (isset($args[$old])) {
             $args[$key] = $args[$old];
             unset($args[$old]);
         }
     }
     if (empty($args['name'])) {
         return trigger_error('Empty name', E_USER_WARNING);
     }
     $args = wp_parse_args($args, array('value' => NULL, 'desc' => '', 'desc_pos' => ''));
     if (isset($args['extra']) && !is_array($args['extra'])) {
         $args['extra'] = shortcode_parse_atts($args['extra']);
     }
     self::$cur_name = self::get_name($args['name']);
     self::$cur_val = self::get_value($args['name'], $formdata);
     switch ($args['type']) {
         case 'select':
         case 'radio':
             if (!is_array($args['value'])) {
                 return trigger_error("'value' argument is expected to be an array", E_USER_WARNING);
             }
             return self::_single_choice($args);
             break;
         case 'checkbox':
             if (is_array($args['value'])) {
                 return self::_multiple_choice($args);
             } else {
                 return self::_checkbox($args);
             }
             break;
         default:
             return self::_input($args);
     }
 }
コード例 #16
0
 function page_content()
 {
     $data = array('columns' => array(__('Name', P2P_TEXTDOMAIN), __('Information', P2P_TEXTDOMAIN), __('Connections', P2P_TEXTDOMAIN)));
     $connection_counts = $this->get_connection_counts();
     if (empty($connection_counts)) {
         $data['has-rows'] = false;
         $data['no-rows'] = __('No connection types registered.', P2P_TEXTDOMAIN);
         $data['no-rows2'] = sprintf(__('To register a connection type, see <a href="%s">the wiki</a>.', P2P_TEXTDOMAIN), 'https://github.com/scribu/wp-posts-to-posts/wiki/');
     } else {
         $data['has-rows'] = array(true);
         foreach ($connection_counts as $p2p_type => $count) {
             $row = array('p2p_type' => $p2p_type, 'count' => number_format_i18n($count));
             $ctype = p2p_type($p2p_type);
             if ($ctype) {
                 $row['desc'] = $ctype->get_desc();
             } else {
                 $row['desc'] = __('Convert to registered connection type:', P2P_TEXTDOMAIN) . scbForms::form_wrap($this->get_dropdown($p2p_type), $this->nonce);
                 $row['class'] = 'error';
             }
             $data['rows'][] = $row;
         }
     }
     echo P2P_Mustache::render('connection-types', $data);
 }
コード例 #17
0
ファイル: dropdown.php プロジェクト: Nsteinel/jmb
 protected function render_dropdown()
 {
     $direction = $this->ctype->flip_direction()->get_direction();
     return scbForms::input(array('type' => 'select', 'name' => array('p2p', $this->ctype->name, $direction), 'choices' => self::get_choices($this->ctype), 'text' => $this->title), $_GET);
 }
コード例 #18
0
ファイル: class-tabs-page.php プロジェクト: kalushta/darom
 public function table_row($field, $formdata = false)
 {
     if (empty($field['tip'])) {
         $tip = '';
     } else {
         $tip = html('i', array('class' => 'at at-tip', 'data-tooltip' => APP_ToolTips::supports_wp_pointer() ? $field['tip'] : __('Click for more info', APP_TD)));
         if (!APP_ToolTips::supports_wp_pointer()) {
             $tip .= html("div class='tip-content'", $field['tip']);
         }
     }
     if (isset($field['desc'])) {
         // wrap textareas and regular-text fields in <p> tag
         // TODO: doesn't catch wrap_upload() instances for buttons
         if (in_array($field['type'], array('text', 'textarea', 'submit'))) {
             if (!isset($field['extra']['class']) || strpos($field['extra']['class'], 'small-text') === false) {
                 $field['desc'] = html('p class="description"', $field['desc']);
             }
         }
     }
     $input = scbForms::input($field, $formdata);
     // wrap radio buttons in a <fieldset> tag following what WP also does
     if ('radio' == $field['type']) {
         $input = html('fieldset', $input);
     }
     return html("tr", html("th scope='row app-row'", html('label for="' . esc_attr($field['title']) . '"', $field['title']) . $tip), html("td", $input));
 }
コード例 #19
0
ファイル: settings.php プロジェクト: kalushta/darom
 function permalink_section_add_option($option)
 {
     global $cp_options;
     echo scbForms::input(array('type' => 'text', 'name' => 'cp_options[' . $option['id'] . ']', 'extra' => array('size' => 53), 'value' => $cp_options->{$option}['id']));
 }
コード例 #20
0
ファイル: Forms.php プロジェクト: ugurbastan/swe-574-group4
 function input($args)
 {
     $value = scbForms::get_value($args['name'], $this->data);
     if (!empty($this->prefix)) {
         $args['name'] = array_merge($this->prefix, (array) $args['name']);
     }
     return scbForms::input_with_value($args, $value);
 }
コード例 #21
0
 public function table_row($field, $formdata = false)
 {
     if (empty($field['tip'])) {
         $tip = '';
     } else {
         $tip = html("img", array('class' => 'tip-icon', 'title' => __('Help', APP_TD), 'src' => appthemes_framework_image('help.png')));
         $tip .= html("div class='tip-content'", $field['tip']);
     }
     if (isset($field['desc'])) {
         $field['desc'] = html('span class="description"', $field['desc']);
     }
     return html("tr", html("th scope='row'", $field['title']), html("td class='tip'", $tip), html("td", scbForms::input($field, $this->options->get())));
 }
コード例 #22
0
ファイル: AdminPage.php プロジェクト: realfluid/umbaugh
	function input( $args, $formdata = array() ) {
		if ( empty( $formdata ) )
			$formdata = $this->formdata;

		if ( isset( $args['name_tree'] ) ) {
			$tree = ( array ) $args['name_tree'];
			unset( $args['name_tree'] );

			$value = $formdata;
			$name = $this->option_name;
			foreach ( $tree as $key ) {
				$value = $value[$key];
				$name .= '[' . $key . ']';
			}

			$args['name'] = $name;
			unset( $args['names'] );

			unset( $args['values'] );

			$formdata = array( $name => $value );
		}

		return scbForms::input( $args, $formdata );
	}
コード例 #23
0
function _appthemes_form_serialize($data, $name)
{
    if (!is_array($data)) {
        echo html('input', array('type' => 'hidden', 'name' => scbForms::get_name($name), 'value' => $data)) . "\n";
        return;
    }
    foreach ($data as $key => $value) {
        _appthemes_form_serialize($value, array_merge($name, array($key)));
    }
}
コード例 #24
0
ファイル: AdminPage.php プロジェクト: sontv1003/vtcacademy
 function form_wrap($content, $submit_button = true)
 {
     if (is_array($submit_button)) {
         $content .= $this->submit_button($submit_button);
     } elseif (true === $submit_button) {
         $content .= $this->submit_button();
     } elseif (false !== strpos($submit_button, '<input')) {
         $content .= $submit_button;
     } elseif (false !== $submit_button) {
         $button_args = array_slice(func_get_args(), 1);
         $content .= call_user_func_array(array($this, 'submit_button'), $button_args);
     }
     return scbForms::form_wrap($content, $this->nonce);
 }
コード例 #25
0
ファイル: class-widget.php プロジェクト: kalushta/darom
 /**
  * Validates and updates widget settings.
  *
  * @param array $new_instance New settings for this instance.
  * @param array $old_instance Old settings for this instance.
  *
  * @return array
  */
 public function update($new_instance, $old_instance)
 {
     $form_fields = $this->form_fields();
     $to_update = scbForms::validate_post_data($form_fields, $new_instance, $old_instance);
     return $to_update;
 }
コード例 #26
0
ファイル: user.php プロジェクト: postmatic/beta-dist
 /**
  * @since 1.0.0
  *
  * @param Prompt_Interface_Subscribable $list
  * @return string
  */
 protected function profile_subscription_checkbox(Prompt_Interface_Subscribable $list)
 {
     $name = strtolower(get_class($list)) . '_subscribed[]';
     return scbForms::input(array('name' => $name, 'type' => 'checkbox', 'value' => $list->id(), 'desc' => $list->subscribe_prompt(), 'checked' => $list->is_subscribed($this->id), 'extra' => array('disabled' => !$list->is_subscribed($this->id) and !$this->is_current_user())));
 }
コード例 #27
0
 protected function save($post_id)
 {
     $form_fields = $this->form_fields();
     $to_update = scbForms::validate_post_data($form_fields);
     // Filter data
     $to_update = $this->before_save($to_update, $post_id);
     // Validate dataset
     $is_valid = $this->validate_post_data($to_update, $post_id);
     if ($is_valid instanceof WP_Error && $is_valid->get_error_codes()) {
         $error_data = array('fields' => $is_valid->get_error_codes(), 'data' => $to_update);
         update_post_meta($post_id, '_error_data_' . $this->id, $error_data);
         $location = add_query_arg('message', 1, get_edit_post_link($post_id, 'url'));
         wp_redirect(apply_filters('redirect_post_location', $location, $post_id));
         exit;
     }
     foreach ($to_update as $key => $value) {
         update_post_meta($post_id, $key, $value);
     }
 }
コード例 #28
0
ファイル: Forms.php プロジェクト: kalushta/darom
 public function render($value = null)
 {
     if (null === $value && isset($this->default)) {
         $value = $this->default;
     }
     $args = $this->args;
     if (null !== $value) {
         $this->_set_value($args, $value);
     }
     $args['name'] = scbForms::get_name($args['name']);
     return str_replace(scbForms::TOKEN, $this->_render($args), $this->wrap);
 }
コード例 #29
0
 /**
  * Saves metabox form data.
  *
  * @param int $user_id
  *
  * @return void
  */
 public function save($user_id)
 {
     if (!current_user_can('edit_user', $user_id)) {
         return;
     }
     $this->user_id = $user_id;
     $form_fields = $this->form_fields();
     $to_update = $this->before_save(scbForms::validate_post_data($form_fields), $user_id);
     $form_fields = $this->set_keys($form_fields);
     $this->validate_fields_data($to_update, $form_fields, $user_id);
     if (!empty($this->errors)) {
         return false;
     }
     foreach ($to_update as $key => $value) {
         update_user_meta($user_id, $key, $value);
     }
 }
コード例 #30
0
ファイル: Forms.php プロジェクト: joaosigno/dazake-job
 function input($args)
 {
     $default = isset($args['default']) ? $args['default'] : null;
     $value = scbForms::get_value($args['name'], $this->data, $default);
     if (!empty($this->prefix)) {
         $args['name'] = array_merge($this->prefix, (array) $args['name']);
     }
     return scbForms::input_with_value($args, $value);
 }