/** * Outputs the html selected attribute * * @since 2.0.4 * @param array $values * @param string $current * @param bool $echo * @return string html attribute or empty string */ function wpmm_multiselect($values, $current) { foreach ($values as $k => $role) { $is_selected = __checked_selected_helper($role, $current, false, 'selected'); if (!empty($is_selected)) { return $is_selected; break; } } }
/** * @since 3.0 * @see /wp-includes/general-template.php */ function disabled($disabled, $current = true, $echo = true) { if (function_exists('disabled')) { return disabled($disabled, $current, $echo); } else { if (function_exists('__checked_selected_helper')) { return __checked_selected_helper($disabled, $current, $echo, 'disabled'); } } $result = $disabled == $current ? " disabled='disabled'" : ''; if ($echo) { echo $result; } return $result; }
public function get_meta_box($post) { $use_caption = get_post_meta($post->ID, 'ss-slide-use-caption', true); $use_caption_title = get_post_meta($post->ID, 'ss-slide-use-caption-title', true); $link = get_post_meta($post->ID, 'ss-slide-link', true); $link_new_window = get_post_meta($post->ID, 'ss-slide-link-new-window', true); wp_nonce_field('ss-slide-edit', 'ss-slide-options-nonce'); ?> <p> <strong>Caption</strong><br /> <label> <input type="checkbox" name="ss-slide-use-caption" id="ss-slide-use-caption" value="1" <?php __checked_selected_helper('1', $use_caption, true, 'checked'); ?> /> Enable caption for this slide. </label><br /> <label> <input type="checkbox" name="ss-slide-use-caption-title" id="ss-slide-use-caption-title" value="1" <?php __checked_selected_helper('1', $use_caption_title, true, 'checked'); ?> /> Add slide title to caption. </label> </p> <p> <strong>Link</strong><br /> <input type="text" name="ss-slide-link" id="ss-slide-link" value="<?php echo $link; ?> " style="width: 100%;" /><br /> <label><input type="checkbox" name="ss-slide-link-new-window" id="ss-slide-link-new-window" value="1" <?php __checked_selected_helper('1', $link_new_window, true, 'checked'); ?> /> Open link in new window.</label> </p> <?php }
/** * Outputs the html disabled attribute. * * Compares the first two arguments and if identical marks as disabled * * @since 3.0.0 * * @param mixed $disabled One of the values to compare * @param mixed $current (true) The other value to compare if not just true * @param bool $echo Whether to echo or just return the string * @return string html attribute or empty string */ function disabled($disabled, $current = true, $echo = true) { return __checked_selected_helper($disabled, $current, $echo, 'disabled'); }
/** * Similar to the WordPress `selected()`, `checked()`, and `disabled()` functions, except it allows arrays to be passed as current value * * @todo Move to helper-functions.php * @see selected() WordPress core function * * @param string $value One of the values to compare * @param mixed $current (true) The other value to compare if not just true * @param bool $echo Whether to echo or just return the string * @param string $type The type of checked|selected|disabled we are doing * * @return string html attribute or empty string */ function gv_selected($value, $current, $echo = true, $type = 'selected') { $output = ''; if (is_array($current)) { if (in_array($value, $current)) { $output = __checked_selected_helper(true, true, false, $type); } } else { $output = __checked_selected_helper($value, $current, false, $type); } if ($echo) { echo $output; } return $output; }
/** * Render Authorization meta box. */ function metabox_authorization_content($data) { if (!$this->goauth->is_authorized()) { ?> <form action="<?php echo $this->redirect_uri; ?> " method="post"> <p><?php _e('Before backups can be uploaded to Google Drive, you need to authorize the plugin and give it permission to make changes on your behalf.', $this->text_domain); ?> </p> <p> <label for="client_id"><?php _e('Client ID', $this->text_domain); ?> </label> <input id="client_id" name="client_id" type='text' <?php __checked_selected_helper(defined('BACKUP_CLIENT_ID'), true, true, 'readonly'); ?> class="large-text" value='<?php echo esc_html($this->options['client_id']); ?> ' /> </p> <p> <label for="client_secret"><?php _e('Client secret', $this->text_domain); ?> <input id="client_secret" name='client_secret' type='text' <?php __checked_selected_helper(defined('BACKUP_CLIENT_SECRET'), true, true, 'readonly'); ?> class="large-text" value='<?php echo esc_html($this->options['client_secret']); ?> ' /> </p> <p class="para hide-if-js"> <label for="refresh_token"><?php _e('Refresh token', $this->text_domain); ?> <input id="refresh_token" name='refresh_token' type='text' <?php __checked_selected_helper(defined('BACKUP_REFRESH_TOKEN'), true, true, 'readonly'); ?> class="large-text" value='<?php echo esc_html($this->options['refresh_token']); ?> ' /> </p> <p> <input name="authorize" type="submit" class="button-secondary" value="<?php _e('Authorize', $this->text_domain); ?> " /> <a href="#refresh_token" class="show-para hide-if-no-js"><?php _e('More', $this->text_domain); ?> </a> </p> </form> <?php } else { ?> <?php if (!empty($this->options['user_info'])) { ?> <div id="dashboard_right_now" class="column-username"> <?php if ($this->options['user_info']['picture']) { ?> <img src="<?php echo $this->options['user_info']['picture']; ?> " width="50" heigth="50" /> <?php } else { $default = get_option('avatar_default'); if (empty($default)) { $default = 'mystery'; } echo get_avatar($this->options['user_info']['email'], 50, $default); } ?> <strong><?php echo $this->options['user_info']['name']; ?> </strong><br /> <?php echo $this->options['user_info']['email']; ?> <br /> <span class="approved"><?php _e("Authorized", $this->text_domain); ?> </span> </div> <?php } ?> <p><?php _e('Authorization to use Google Drive has been granted.', $this->text_domain); ?> </p> <p class="para hide-if-js"><input type="text" readonly="readonly" class="click-select large-text" value="<?php echo esc_html($this->options['refresh_token']); ?> " /></p> <p><?php if (defined('BACKUP_REFRESH_TOKEN')) { ?> <a class="button disabled"><?php } else { ?> <a href="<?php echo $this->redirect_uri; ?> &state=revoke" class="button-secondary"><?php } _e('Revoke access', $this->text_domain); ?> </a> <a href="#token-select" class="show-para hide-if-no-js"><?php _e('Show token', $this->text_domain); ?> </a></p><?php } }
public function page_settings() { ?> <div class="wrap"> <div class="icon32" id="icon-options-general"></div> <h2>Default Settings</h2> <?php if ('true' == $_GET['settings-updated']) { ?> <div id="message" class="updated below-h2"> <p>Simple Slides default settings has been succesfully updated.</p> </div> <?php } ?> <p> Use <strong>shortcode attributes</strong> to override these default settings. Shortcode attribute names are indicated below each setting label. </p> <p> For more information, please refer to the <a target="_blank" href="http://apocalypseboy.com/simple-slides/">plugin documentation</a>. </p> <form action="options.php" method="post"> <?php $settings = $this->get_settings(); echo settings_fields($this->settings_name); ?> <table class="form-table"> <tr> <th scope="row"> <label>Theme</label><br /> <span class="description">[theme]</span> </th> <td> <select name="<?php echo $this->settings_name; ?> [script][script_settings_nojs][theme]"> <option value="default" <?php __checked_selected_helper('default', $settings['script']['script_settings_nojs']['theme'], true, 'selected'); ?> >Default</option> <option value="clean" <?php __checked_selected_helper('clean', $settings['script']['script_settings_nojs']['theme'], true, 'selected'); ?> >Clean</option> <option value="bar" <?php __checked_selected_helper('bar', $settings['script']['script_settings_nojs']['theme'], true, 'selected'); ?> >Bar</option> <option value="dark" <?php __checked_selected_helper('dark', $settings['script']['script_settings_nojs']['theme'], true, 'selected'); ?> >Dark</option> <option value="light" <?php __checked_selected_helper('light', $settings['script']['script_settings_nojs']['theme'], true, 'selected'); ?> >Light</option> </select> <span class="description"></span> </td> </tr> <tr> <th scope="row"> <label>Image Size</label><br /> <span class="description">[image_size]</span> </th> <td> <input class="regular-text" type="text" name="<?php echo $this->settings_name; ?> [script][script_settings_nojs][image_size]" value="<?php echo $settings['script']['script_settings_nojs']['image_size']; ?> " /><br /> <span class="description"></span> </td> </tr> <tr> <th scope="row"> <label>Width</label><br /> <span class="description">[width]</span> </th> <td> <input class="regular-text" type="text" name="<?php echo $this->settings_name; ?> [script][script_settings_nojs][width]" value="<?php echo $settings['script']['script_settings_nojs']['width']; ?> " /><br /> <span class="description">Can be any css value that's appropiate for width. (e.g. auto, 300px, 95%)</span> </td> </tr> <tr> <th scope="row"> <label>Height</label><br /> <span class="description">[height]</span> </th> <td> <input class="regular-text" type="text" name="<?php echo $this->settings_name; ?> [script][script_settings_nojs][height]" value="<?php echo $settings['script']['script_settings_nojs']['height']; ?> " /><br /> <span class="description">Can be any css value that's appropiate for width. (e.g. auto, 300px, 95%)</span> </td> </tr> <tr> <th scope="row"> <label>Effect</label><br /> <span class="description">[effect]</span> </th> <td> <select name="<?php echo $this->settings_name; ?> [script][script_settings][effect]"> <option value="sliceDown" <?php __checked_selected_helper('sliceDown', $settings['script']['script_settings']['effect'], true, 'selected'); ?> >Slice Down</option> <option value="sliceDownLeft" <?php __checked_selected_helper('sliceDownLeft', $settings['script']['script_settings']['effect'], true, 'selected'); ?> >Slice Down Left</option> <option value="sliceUp" <?php __checked_selected_helper('sliceUp', $settings['script']['script_settings']['effect'], true, 'selected'); ?> >Slice Up</option> <option value="sliceUpLeft" <?php __checked_selected_helper('sliceUpLeft', $settings['script']['script_settings']['effect'], true, 'selected'); ?> >Slice Up Left</option> <option value="sliceUpDown" <?php __checked_selected_helper('sliceUpDown', $settings['script']['script_settings']['effect'], true, 'selected'); ?> >Slice Up Down</option> <option value="sliceUpDownLeft" <?php __checked_selected_helper('sliceUpDownLeft', $settings['script']['script_settings']['effect'], true, 'selected'); ?> >Slice Up Down Left</option> <option value="fold" <?php __checked_selected_helper('fold', $settings['script']['script_settings']['effect'], true, 'selected'); ?> >Fold</option> <option value="fade" <?php __checked_selected_helper('fade', $settings['script']['script_settings']['effect'], true, 'selected'); ?> >Fade</option> <option value="random" <?php __checked_selected_helper('random', $settings['script']['script_settings']['effect'], true, 'selected'); ?> >Random</option> <option value="slideInRight" <?php __checked_selected_helper('slideInRight', $settings['script']['script_settings']['effect'], true, 'selected'); ?> >Slide In Right</option> <option value="slideInLeft" <?php __checked_selected_helper('slideInLeft', $settings['script']['script_settings']['effect'], true, 'selected'); ?> >Slide In Left</option> <option value="boxRandom" <?php __checked_selected_helper('boxRandom', $settings['script']['script_settings']['effect'], true, 'selected'); ?> >Box Random</option> <option value="boxRain" <?php __checked_selected_helper('boxRain', $settings['script']['script_settings']['effect'], true, 'selected'); ?> >Box Rain</option> <option value="boxRainReverse" <?php __checked_selected_helper('boxRainReverse', $settings['script']['script_settings']['effect'], true, 'selected'); ?> >Box Rain Reverse</option> <option value="boxRainGrow" <?php __checked_selected_helper('boxRainGrow', $settings['script']['script_settings']['effect'], true, 'selected'); ?> >Box Rain Grow</option> <option value="boxRainGrowReverse" <?php __checked_selected_helper('boxRainGrowReverse', $settings['script']['script_settings']['effect'], true, 'selected'); ?> >Box Rain Grow Reverse</option> </select><br /> <span class="description">Effect to be used for all slides.</span> </td> </tr> <tr> <th scope="row"> <label>Slices</label><br /> <span class="description">[<?php echo $this->global_settings['script']['script_settings_map']['slices']; ?> ]</span> </th> <td> <input class="regular-text" type="text" name="<?php echo $this->settings_name; ?> [script][script_settings][slices]" value="<?php echo $settings['script']['script_settings']['slices']; ?> " /><br /> <span class="description">Number of silces to animate. For slice animations only.</span> </td> </tr> <tr> <th scope="row"> <label>Box Columns</label><br /> <span class="description">[<?php echo $this->global_settings['script']['script_settings_map']['boxCols']; ?> ]</span> </th> <td> <input class="regular-text" type="text" name="<?php echo $this->settings_name; ?> [script][script_settings][boxCols]" value="<?php echo $settings['script']['script_settings']['boxCols']; ?> " /><br /> <span class="description">Number of columns to animate. For box animations only.</span> </td> </tr> <tr> <th scope="row"> <label>Box Rows</label><br /> <span class="description">[<?php echo $this->global_settings['script']['script_settings_map']['boxRows']; ?> ]</span> </th> <td> <input class="regular-text" type="text" name="<?php echo $this->settings_name; ?> [script][script_settings][boxRows]" value="<?php echo $settings['script']['script_settings']['boxRows']; ?> " /><br /> <span class="description">Number of rows to animate. For box animations only.</span> </td> </tr> <tr> <th scope="row"> <label>Animation Speed</label><br /> <span class="description">[<?php echo $this->global_settings['script']['script_settings_map']['animSpeed']; ?> ]</span> </th> <td> <input class="regular-text" type="text" name="<?php echo $this->settings_name; ?> [script][script_settings][animSpeed]" value="<?php echo $settings['script']['script_settings']['animSpeed']; ?> " /><br /> <span class="description">Slide transition speed in milliseconds.</span> </td> </tr> <tr> <tr> <th scope="row"> <label>Pause Time</label><br /> <span class="description">[<?php echo $this->global_settings['script']['script_settings_map']['pauseTime']; ?> ]</span> </th> <td> <input class="regular-text" type="text" name="<?php echo $this->settings_name; ?> [script][script_settings][pauseTime]" value="<?php echo $settings['script']['script_settings']['pauseTime']; ?> " /><br /> <span class="description">Slide pause time in milliseconds.</span> </td> </tr> <tr> <th scope="row"> <label>Direction Navigation</label><br /> <span class="description">[<?php echo $this->global_settings['script']['script_settings_map']['directionNav']; ?> ]</span> </th> <td> <select name="<?php echo $this->settings_name; ?> [script][script_settings][directionNav]"> <option value="1" <?php __checked_selected_helper('1', $settings['script']['script_settings']['directionNav'], true, 'selected'); ?> >Yes</option> <option value="0" <?php __checked_selected_helper('0', $settings['script']['script_settings']['directionNav'], true, 'selected'); ?> >No</option> </select><br /> <span class="description">Show the next and prev navigation buttons.</span> </td> </tr> <tr> <th scope="row"> <label>Control Navigation</label><br /> <span class="description">[<?php echo $this->global_settings['script']['script_settings_map']['controlNav']; ?> ]</span> </th> <td> <select name="<?php echo $this->settings_name; ?> [script][script_settings][controlNav]"> <option value="1" <?php __checked_selected_helper('1', $settings['script']['script_settings']['controlNav'], true, 'selected'); ?> >Yes</option> <option value="0" <?php __checked_selected_helper('0', $settings['script']['script_settings']['controlNav'], true, 'selected'); ?> >No</option> </select><br /> <span class="description">Show the control navigation buttons.</span> </td> </tr> <tr> <th scope="row"> <label>Pause On Hover</label><br /> <span class="description">[<?php echo $this->global_settings['script']['script_settings_map']['pauseOnHover']; ?> ]</span> </th> <td> <select name="<?php echo $this->settings_name; ?> [script][script_settings][pauseOnHover]"> <option value="1" <?php __checked_selected_helper('1', $settings['script']['script_settings']['pauseOnHover'], true, 'selected'); ?> >Yes</option> <option value="0" <?php __checked_selected_helper('0', $settings['script']['script_settings']['pauseOnHover'], true, 'selected'); ?> >No</option> </select><br /> <span class="description">Stop slide transition if the mouse is hovered.</span> </td> </tr> <tr> <th scope="row"> <label>Previous Text</label><br /> <span class="description">[<?php echo $this->global_settings['script']['script_settings_map']['prevText']; ?> ]</span> </th> <td> <input class="regular-text" type="text" name="<?php echo $this->settings_name; ?> [script][script_settings][prevText]" value="<?php echo $settings['script']['script_settings']['prevText']; ?> " /><br /> <span class="description">Text for the prev navigation button. May not be visible if button is styled.</span> </td> </tr> <tr> <th scope="row"> <label>Next Text</label><br /> <span class="description">[<?php echo $this->global_settings['script']['script_settings_map']['nextText']; ?> ]</span> </th> <td> <input class="regular-text" type="text" name="<?php echo $this->settings_name; ?> [script][script_settings][nextText]" value="<?php echo $settings['script']['script_settings']['nextText']; ?> " /><br /> <span class="description">Text for the next navigation button. May not visible if button is styled.</span> </td> </tr> <tr> <th scope="row"> <label>Random Start</label><br /> <span class="description">[<?php echo $this->global_settings['script']['script_settings_map']['randomStart']; ?> ]</span> </th> <td> <select name="<?php echo $this->settings_name; ?> [script][script_settings][randomStart]"> <option value="1" <?php __checked_selected_helper('1', $settings['script']['script_settings']['randomStart'], true, 'selected'); ?> >Yes</option> <option value="0" <?php __checked_selected_helper('0', $settings['script']['script_settings']['randomStart'], true, 'selected'); ?> >No</option> </select><br /> <span class="description">Start slider on a random slide.</span> </td> </tr> </table> <p class="submit"><input type="submit" value="Save Changes" class="button-primary" id="submit" name="submit"></p> </form> </div> <?php }
/** * Display Dropdown callback: displays a harvesthq.github.io/chosen/ dropdown. * special arguments: * * - bool required * - bool multiple * - array | string value * - array items | callable itemsCallback * @param $args * @return mixed|string */ public function displayDropdown($args) { $key = $args['post']->ID . '_' . $args['key']; $html = $this->getTemplate($args, $key); if (isset($args['name'])) { $name = $args['name']; } else { // Get the current value $name = $key; } $attr = ''; if (isset($args['required'])) { $attr .= __checked_selected_helper($args['required'], true, false, 'required'); } $singleValue = true; if (isset($args['multiple']) && $args['multiple']) { $attr .= ' multiple'; $arrayNotation = '[]'; if (substr($name, -strlen($arrayNotation)) !== $arrayNotation) { $name .= $arrayNotation; } $singleValue = false; } if (isset($args['value']) && (!$singleValue || is_string($args['value']))) { $value = $args['value']; } elseif (isset($args['value'][0]) && $singleValue) { $value = $args['value'][0]; } else { // Get the current value $value = get_post_meta($args['post']->ID, $args['key'], $singleValue); if (!$singleValue) { $value = array_filter($value); } } $items = $args['items']; if (isset($args['itemsCallback']) && is_callable($args['itemsCallback'])) { $items = callUserFunctionWithSafeArguments($args['itemsCallback'], array($args)); } if (isset($args['allow_single_deselect']) && $args['allow_single_deselect'] == true) { $items = array(0 => array('title' => '')) + $items; } $options = self::convertDropdownItemsToOptions($items, $value, $singleValue); $select = '<select name="' . $name . '" id="' . $key . '" ' . $attr . '>' . implode('', $options) . '</select>'; $chosenArguments = array_merge(array('width' => '100%'), $args); $chosenKey = str_replace('-', '_', $key) . '_chosen'; // only call the sortable method if it was requested $sortableCall = ''; if ($chosenArguments['sortable'] != false) { $sortableCall = '.chosenSortable()'; } // convert array to object recursively $chosenArgumentsObject = json_decode(json_encode($chosenArguments), FALSE); $chosenArgumentsJson = json_encode($chosenArgumentsObject); $select .= ' <script> (function ($) { $(document).ready(function(){ $("#' . $key . '").on("chosen:ready change", function(evt, params) { $("#' . $chosenKey . ' .search-choice").each(function(){ // compare label to option text var label = $(this).text().trim(); var options = $("#' . $key . '").find("option").filter(function(){ return $(this).text().trim() == label; }); if(options.length > 0){ var option = options[0]; if($(option).data("url")){ if(!$(this).hasClass("has-link-action")){ $(".search-choice-close", this).before("<a class=\\"search-choice-link\\" href=\\"" + $(option).data("url") + "\\" ></a>"); $(this).addClass("has-link-action"); } } if($(option).data("image")){ if(!$(this).hasClass("has-image")){ $("span", this).before("<img class=\\"search-choice-image\\" src=\\"" + $(option).data("image") + "\\" />"); $(this).addClass("has-image"); } } } }); $("#' . $chosenKey . ' .search-choice-link").click(function(e){ // chosen is registered on parent, stop the propagation, but don\'t prevent the default action (i.e. browswer link) e.stopPropagation(); }); }); $("#' . $key . '").chosen(' . $chosenArgumentsJson . ')' . $sortableCall . '; }); }(jQuery)); </script> '; $html = str_replace('{input}', $select, $html); return $html; }
_e("Local backups as well as other files created by the plugin will be stored on this path.", $this->text_domain); ?> </p> </td> </tr> <?php if ($this->goauth->is_authorized()) { ?> <tr valign="top"> <th scope="row"><label for="drive_folder"><?php _e('Drive folder ID', $this->text_domain); ?> </label></th> <td> <input id="drive_folder" name="drive_folder" type="text" <?php __checked_selected_helper(defined('BACKUP_DRIVE_FOLDER'), true, true, 'readonly'); ?> class="regular-text code" value="<?php echo esc_html($this->options['drive_folder']); ?> " /> <p class="description"><?php _e('Backups will be uploaded to this folder. Leave empty to save in root folder.', $this->text_domain); ?> </p> </td> </tr> <?php } ?> <tr valign="top">