Esempio n. 1
0
 function select_privacy_ui($echo = true, $select_id = false)
 {
     global $rtmedia;
     if (!is_rtmedia_privacy_enable()) {
         return false;
     }
     if (!is_rtmedia_privacy_user_overide()) {
         return false;
     }
     global $rtmedia_media;
     $default = 0;
     if (isset($rtmedia_media->privacy)) {
         $default = $rtmedia_media->privacy;
     } else {
         $default = get_user_meta(get_current_user_id(), 'rtmedia-default-privacy', true);
         if ($default === false || $default === '') {
             $default = get_rtmedia_default_privacy();
         }
     }
     $form = new rtForm();
     $attributes = array('name' => 'privacy', 'class' => array('privacy'));
     if ($select_id && $select_id != "") {
         $attributes['id'] = $select_id;
     }
     global $rtmedia;
     $privacy_levels = $rtmedia->privacy_settings['levels'];
     if (class_exists('BuddyPress')) {
         if (!bp_is_active('friends')) {
             unset($privacy_levels[40]);
         }
     } else {
         unset($privacy_levels[40]);
     }
     foreach ($privacy_levels as $key => $value) {
         $privacy = explode(' - ', $value);
         $attributes['rtForm_options'][] = array($privacy[0] => $key, 'selected' => $key == $default ? 1 : 0);
     }
     if ($echo) {
         echo $form->get_select($attributes);
     } else {
         return $form->get_select($attributes);
     }
 }
 protected function generate_dimensions($attributes)
 {
     $element = "rtDimension";
     global $rtmedia;
     $defaults = array('desc' => '', 'show_desc' => false);
     $attributes = wp_parse_args($attributes, $defaults);
     extract($attributes);
     $html = '<div ';
     if (isset($attributes['id'])) {
         $html .= 'id="' . $attributes['id'] . '" ';
     } else {
         $html .= 'id="' . $this->get_default_class() . '-' . $this->get_default_id() . '" ';
         $this->update_default_id();
     }
     if (isset($attributes['class'])) {
         $html .= self::embedd_class($element, $attributes['class']);
     } else {
         $html .= self::embedd_class($element);
     }
     $html .= '>';
     $html .= parent::get_textbox(array('name' => "rtmedia-options[{$key}_width]", 'value' => $width, 'class' => array("small-text large-offset-1"), 'show_desc' => $show_desc));
     if (isset($height)) {
         $html .= parent::get_textbox(array('name' => "rtmedia-options[{$key}_height]", 'value' => $height, 'class' => array("small-text large-offset-1"), 'show_desc' => $show_desc));
     }
     if (isset($crop)) {
         $html .= parent::get_checkbox(array('name' => "rtmedia-options[{$key}_crop]", 'rtForm_options' => array(array('' => 1, 'checked' => $crop)), 'class' => array("large-offset-1"), 'show_desc' => $show_desc));
     }
     if ($desc && $show_desc) {
         $html .= '<span class="clearfix large-offset-3 description">' . $desc . '</span>';
     }
     $html .= '</div>';
     if (isset($attributes['label'])) {
         $html = parent::enclose_label('container', $html, $attributes['label']);
     }
     return $html;
 }
Esempio n. 3
0
 /**
  * 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 textbox in admin options.
  *
  * @access static
  *
  * @param  array $args
  *
  * @return void
  */
 public static function textbox($args)
 {
     global $rtmedia;
     $options = $rtmedia->options;
     $defaults = array('key' => '', 'desc' => '');
     $args = wp_parse_args($args, $defaults);
     extract($args);
     if (!isset($value)) {
         trigger_error(__('Please provide a "value" in the argument.', 'rtmedia'));
         return;
     }
     if (!empty($key)) {
         $args['name'] = 'rtmedia-options[' . $key . ']';
     }
     $args['value'] = $value;
     $numObj = new rtForm();
     echo $numObj->get_textbox($args);
 }
Esempio n. 5
0
 function select_privacy_ui($echo = true, $element_id = false, $element_class = array(), $selected = false)
 {
     global $rtmedia;
     if (!is_rtmedia_privacy_enable()) {
         return false;
     }
     if (!is_rtmedia_privacy_user_overide()) {
         return false;
     }
     global $rtmedia_media;
     if (false !== $selected) {
         $default = $selected;
     } elseif (isset($rtmedia_media->privacy)) {
         $default = $rtmedia_media->privacy;
     } else {
         //todo user attribute
         $default = get_user_meta(get_current_user_id(), 'rtmedia-default-privacy', true);
         if (false === $default || '' === $default) {
             $default = get_rtmedia_default_privacy();
         }
     }
     $form = new rtForm();
     $attributes_class = array('privacy');
     if (!empty($element_class)) {
         if (!is_array($element_class)) {
             $attributes_class = array_merge($attributes_class, (array) $element_class);
         } else {
             $attributes_class = array_merge($attributes_class, $element_class);
         }
     }
     $attributes = array('name' => 'privacy', 'class' => $attributes_class);
     if ($element_id && '' !== $element_id) {
         $attributes['id'] = $element_id;
     }
     global $rtmedia;
     $privacy_levels = $rtmedia->privacy_settings['levels'];
     if (class_exists('BuddyPress')) {
         if (!bp_is_active('friends')) {
             unset($privacy_levels[40]);
         }
     } else {
         unset($privacy_levels[40]);
     }
     foreach ($privacy_levels as $key => $value) {
         $privacy = explode(' - ', $value);
         $attributes['rtForm_options'][] = array($privacy[0] => $key, 'selected' => intval($default) === $key ? 1 : 0);
     }
     if ($echo) {
         echo $form->get_select($attributes);
         // @codingStandardsIgnoreLine
     } else {
         return $form->get_select($attributes);
     }
 }