Get rtmedia html input type checkbox (get_switch) in admin options.
public get_switch ( string/array $attributes = '' ) : string | ||
$attributes | string/array | |
Результат | string |
public static function checkbox($args, $echo = true) { global $rtmedia; $options = $rtmedia->options; $defaults = array('key' => '', 'desc' => '', 'show_desc' => false); $args = wp_parse_args($args, $defaults); extract($args); if (!isset($value)) { trigger_error(__('Please provide "value" in the argument.', 'rtmedia')); return; } if (!empty($key)) { $args['name'] = 'rtmedia-options[' . $key . ']'; } $args['rtForm_options'] = array(array('' => 1, 'checked' => $value)); $chkObj = new rtForm(); // echo $chkObj->get_checkbox($args); if ($echo) { echo $chkObj->get_switch($args); } else { return $chkObj->get_switch($args); } // echo $chkObj->get_switch_square($args); }
/** * Generate rtmedia dimensions in admin options. * * @access protected * * @param array $attributes * * @return string $html */ protected function generate_dimensions($attributes) { $element = 'rtDimension'; global $rtmedia; $options = $rtmedia->options; $defaults = array('desc' => '', 'show_desc' => false); $attributes = wp_parse_args($attributes, $defaults); extract($attributes); $html = ''; $html .= '<td>' . parent::get_number(array('name' => "rtmedia-options[{$key}_width]", 'value' => $width, 'class' => array('small-text large-offset-1'), 'show_desc' => $show_desc)) . '</td>'; if (isset($height)) { $html .= '<td>' . parent::get_number(array('name' => "rtmedia-options[{$key}_height]", 'value' => $height, 'class' => array('small-text large-offset-1'), 'show_desc' => $show_desc)) . '</td>'; } if (isset($crop)) { $html .= '<td>' . parent::get_switch(array('name' => "rtmedia-options[{$key}_crop]", 'rtForm_options' => array(array('' => 1, 'checked' => $crop)), 'value' => isset($options["rtmedia-options[{$key}_crop]"]) ? $options["rtmedia-options[{$key}_crop]"] : '0', 'show_desc' => $show_desc)) . '</td>'; } if ($desc && $show_desc) { $html .= '<span class="clearfix large-offset-3 description">' . esc_html($desc) . '</span>'; } if (isset($attributes['label'])) { $html = parent::enclose_label('container', $html, $attributes['label']); } return $html; }
/** * Show rtmedia checkbox in admin options. * * @access static * * @param array $args * @param bool $echo * * @return string $chkObj->get_switch( $args ) */ public static function checkbox($args, $echo = true) { $defaults = array('key' => '', 'desc' => '', 'show_desc' => false); $args = wp_parse_args($args, $defaults); extract($args); if (!isset($value)) { trigger_error(esc_html__('Please provide a "value" in the argument.', 'buddypress-media')); return; } if (!empty($key)) { $args['name'] = 'rtmedia-options[' . $key . ']'; } $args['rtForm_options'] = array(array('' => 1, 'checked' => $value)); $chkObj = new rtForm(); if ($echo) { $chkObj->display_switch($args); } else { return $chkObj->get_switch($args); } return; }