/**
     * Missing plugins warning.
     */
    public function missing_plugins_warning()
    {
        if ($this->missing) {
            $missing = '';
            $missing_slugs = array();
            $counter = 0;
            foreach ($this->missing as $title => $data) {
                $url = $data['url'];
                $missing_slugs[] = 'wpml-missing-' . sanitize_title_with_dashes($data['slug']);
                $counter++;
                if (sizeof($this->missing) == $counter) {
                    $sep = '';
                } elseif (sizeof($this->missing) - 1 == $counter) {
                    $sep = ' ' . __('and', 'wpml-translation-management') . ' ';
                } else {
                    $sep = ', ';
                }
                $missing .= '<a href="' . $url . '">' . $title . '</a>' . $sep;
            }
            $missing_slugs_classes = implode(' ', $missing_slugs);
            ?>
			<div class="message error wpml-admin-notice wpml-gfml-inactive <?php 
            echo $missing_slugs_classes;
            ?>
"><p><?php 
            printf(__('Gravity Forms Multilingual is enabled but not effective. It requires %s in order to work.', 'wpml-translation-management'), $missing);
            ?>
</p></div>
			<?php 
        }
    }
Example #2
1
 public static function admin_menu()
 {
     $tribe_settings = TribeSettings::instance();
     // Export entries
     if ($_REQUEST['page'] === 'tribe-events-calendar-registration-export' and !is_null($_REQUEST['id'])) {
         $post_id = $_REQUEST['id'];
         $forms = GFFormsModel::get_forms();
         foreach ($forms as $form) {
             if (strtolower($form->title) == strtolower(self::$formTitle)) {
                 $form_id = $form->id;
                 $entries = GFAPI::get_entries($form_id, array('field_filters' => array(array('key' => '7', 'value' => $post_id))), null, array('offset' => '0', 'page_size' => '1000'));
                 header("Content-type: text/csv");
                 header("Content-Disposition: attachment; filename=" . sanitize_title_with_dashes($entries[0]['6']) . ".csv");
                 header("Pragma: no-cache");
                 header("Expires: 0");
                 echo $entries[0]['6'] . "\n";
                 echo "Date Created, First Name, Last Name, Email, Phone Number, Number of Participants\n";
                 foreach ($entries as $entry) {
                     echo $entry['date_created'] . ',';
                     echo $entry['1'] . ',';
                     echo $entry['2'] . ',';
                     echo $entry['3'] . ',';
                     echo $entry['4'] . ',';
                     echo $entry['5'] . "\n";
                 }
                 die;
             }
         }
     }
 }
Example #3
0
 /**
  * Get info about the fonts available in the current kit
  *
  * @param  string        $kit_id    The id of the kit.
  * @param  bool          $force     True to ignore cached info.
  * @return array|bool               An array of font information, or false if the kit ID is invalid.
  */
 function glyphs_get_typekit_fonts($kit_id = null, $force = false)
 {
     if (null === $kit_id) {
         $kit_id = get_theme_mod('typekit-id', false);
     }
     if (!$kit_id) {
         return false;
     }
     // Get cached font info
     $fonts = get_transient('glyphs-typekit-fonts');
     if (empty($fonts) || true === $force) {
         $fonts = array();
         // Look up the font kit
         $response = wp_remote_get('https://typekit.com/api/v1/json/kits/' . $kit_id . '/published');
         $response_code = wp_remote_retrieve_response_code($response);
         $response_body = json_decode(wp_remote_retrieve_body($response));
         // If the font kit returns a valid response, parse the font info
         if (200 === (int) $response_code && is_object($response_body) && isset($response_body->kit) && isset($response_body->kit->families) && is_array($response_body->kit->families)) {
             foreach ($response_body->kit->families as $family) {
                 $fonts[sanitize_title_with_dashes($family->slug)] = array('label' => wp_strip_all_tags($family->name), 'stack' => isset($family->css_stack) ? wp_strip_all_tags($family->css_stack) : '');
             }
         }
         // Cache the font info
         set_transient('glyphs-typekit-fonts', $fonts, DAY_IN_SECONDS);
     }
     return $fonts;
 }
Example #4
0
function custom_permalinks($title)
{
    $title = sanitize_title_with_dashes($title);
    $toupper = create_function('$m', 'return strtoupper($m[0]);');
    $title = preg_replace_callback('/(%[0-9a-f]{2}?)+/', $toupper, $title);
    return $title;
}
Example #5
0
 public function register_facet($facet_name, $facet_class, $args = array())
 {
     $args = wp_parse_args($args, array('has_rewrite' => FALSE, 'priority' => 5));
     // if the class hasn't been loaded yet and it's an internal class, then load it
     if (!class_exists($facet_class)) {
         // format the filesystem path to try to load this class file from
         $class_path = __DIR__ . '/class-' . str_replace('_', '-', sanitize_title_with_dashes($facet_class)) . '.php';
         // check if this class file is an internal class, try to load it
         if (file_exists($class_path)) {
             require_once $class_path;
         }
     }
     // instantiate the facet
     if (class_exists($facet_class)) {
         $this->facets->{$facet_name} = new $facet_class($facet_name, $args, $this);
     } else {
         return FALSE;
     }
     // register the query var and associate it with this facet
     $query_var = $this->facets->{$facet_name}->register_query_var();
     $this->_query_vars[$query_var] = $facet_name;
     // set the priority to determine how to generate the permalink when there are two or more active facets
     // as with WP hook priority, this should be 1-10
     // facets without pretty permalink rewrite rules get no priority
     if (9 > $args['priority'] && !$args['has_rewrite']) {
         $args['priority'] = 9;
     }
     $this->priority[$facet_name] = (int) $args['priority'];
 }
 public static function register_sidebars()
 {
     $sidebars = apply_filters('piklist_sidebars', array());
     foreach ($sidebars as $sidebar) {
         register_sidebar(array_merge(array('name' => $sidebar['name'], 'id' => sanitize_title_with_dashes($sidebar['name']), 'description' => isset($sidebar['description']) ? $sidebar['description'] : null, 'before_widget' => isset($sidebar['before_widget']) ? $sidebar['before_widget'] : '<div id="%1$s" class="widget-container %2$s">', 'after_widget' => isset($sidebar['after_widget']) ? $sidebar['after_widget'] : '</div>', 'before_title' => isset($sidebar['before_title']) ? $sidebar['before_title'] : '<h3 class="widget-title">', 'after_title' => isset($sidebar['after_title']) ? $sidebar['after_title'] : '</h3>'), $sidebar));
     }
 }
 function fetch_feed($username, $slice = 8)
 {
     $barcelona_remote_url = esc_url('http://instagram.com/' . trim(strtolower($username)));
     $barcelona_transient_key = 'barcelona_instagram_feed_' . sanitize_title_with_dashes($username);
     $slice = absint($slice);
     if (false === ($barcelona_result_data = get_transient($barcelona_transient_key))) {
         $barcelona_remote = wp_remote_get($barcelona_remote_url);
         if (is_wp_error($barcelona_remote) || 200 != wp_remote_retrieve_response_code($barcelona_remote)) {
             return new WP_Error('not-connected', esc_html__('Unable to communicate with Instagram.', 'barcelona'));
         }
         preg_match('#window\\.\\_sharedData\\s\\=\\s(.*?)\\;\\<\\/script\\>#', $barcelona_remote['body'], $barcelona_match);
         if (!empty($barcelona_match)) {
             $barcelona_data = json_decode(end($barcelona_match), true);
             if (is_array($barcelona_data) && isset($barcelona_data['entry_data']['ProfilePage'][0]['user']['media']['nodes'])) {
                 $barcelona_result_data = $barcelona_data['entry_data']['ProfilePage'][0]['user']['media']['nodes'];
             }
         }
         if (is_array($barcelona_result_data)) {
             set_transient($barcelona_transient_key, $barcelona_result_data, 60 * 60 * 2);
         }
     }
     if (empty($barcelona_result_data)) {
         return new WP_Error('no-images', esc_html__('Instagram did not return any images.', 'barcelona'));
     }
     return array_slice($barcelona_result_data, 0, $slice);
 }
Example #8
0
 function BMP()
 {
     // constructor
     global $wpdb;
     require_once ABSPATH . '/wp-admin/includes/plugin.php';
     $this->AllCategories = get_terms('category', array('fields' => 'ids', 'get' => 'all'));
     $this->PluginOptionName = 'BMP_Options';
     $this->TablePrefix = $wpdb->prefix . 'bmp_';
     $this->OptionsTable = $this->TablePrefix . 'options';
     // character encoding
     $this->BlogCharset = get_option('blog_charset');
     $pluginfile = WP_PLUGIN_DIR . '/' . MLM_PLUGIN_NAME . '/mlm-loader .php';
     $this->PluginInfo = (object) get_plugin_data($pluginfile);
     $this->Version = $this->PluginInfo->Version;
     $this->WPVersion = $GLOBALS['wp_version'] + 0;
     $this->pluginPath = $pluginfile;
     $this->pluginDir = dirname($this->pluginPath);
     $this->PluginFile = basename(dirname($pluginfile)) . '/' . basename($pluginfile);
     $this->PluginSlug = sanitize_title_with_dashes($this->PluginInfo->Name);
     $this->pluginBasename = plugin_basename($this->pluginPath);
     //			$this->pluginURL = get_bloginfo('wpurl') . '/' . PLUGINDIR . '/' . dirname(plugin_basename($this->pluginPath));
     //			$this->pluginURL = plugins_url('', $this->pluginPath);
     // this method works even if the WLM folder is just a symlink
     $this->pluginURL = plugins_url('', '/') . basename($this->pluginDir);
 }
 /**
  * Uses WordPress function to sanitize the input string.
  *
  * Limits the output to alphanumeric characters, underscore (_) and dash (-).
  * Whitespace becomes a dash.
  *
  * @param string $string
  * @return string
  */
 public static function sanitizeStringStrong($string)
 {
     $string = str_ireplace('%', '-', $string);
     // Added this because sanitize_title_with_dashes will still allow % to passthru.
     $string = sanitize_title_with_dashes($string);
     return $string;
 }
Example #10
0
 public static function update($id, $values)
 {
     $new_values = array();
     $new_values['frm_param'] = isset($values['param']) ? sanitize_title_with_dashes($values['param']) : '';
     $fields = array('dyncontent', 'insert_loc', 'type', 'show_count', 'form_id', 'entry_id', 'post_id');
     foreach ($fields as $field) {
         if (isset($values[$field])) {
             $new_values['frm_' . $field] = $values[$field];
         }
     }
     if (isset($values['options'])) {
         $new_values['frm_options'] = array();
         foreach ($values['options'] as $key => $value) {
             $new_values['frm_options'][$key] = $value;
         }
     }
     foreach ($new_values as $key => $val) {
         update_post_meta($id, $key, $val);
         unset($key, $val);
     }
     if (!isset($new_values['frm_form_id']) || empty($new_values['frm_form_id'])) {
         return;
     }
     //update post meta of post selected for auto insertion
     if (isset($new_values['frm_insert_loc']) && $new_values['frm_insert_loc'] != 'none' && isset($new_values['frm_post_id']) && (int) $new_values['frm_post_id']) {
         update_post_meta($new_values['frm_post_id'], 'frm_display_id', $id);
     }
 }
 /**
  * Renders the typography field for PP_PB_WF_Fields::render_field_typography()
  *
  * @param $value
  * @param $key
  *
  * @return string
  */
 public function render_field_typography_html($key, $value)
 {
     $html = '';
     // Make sure the size fields are set correctly.
     if (!isset($value['size'])) {
         $value['size'] = $value['size_' . $value['unit']];
     }
     $unit = $value['unit'];
     $html .= '<span class="unit-container ' . esc_attr('unit-' . sanitize_title_with_dashes($unit)) . '">' . "\n";
     /* Size fields */
     $html .= $this->typography_size($key, $value);
     /* Font Unit */
     $html .= '<select class="woo-typography woo-typography-unit" name="' . esc_attr($key . '[unit]') . '" id="' . esc_attr($key . '_unit') . '">' . "\n";
     $html .= '<option value="px" ' . selected($unit, 'px', false) . '">px</option>' . "\n";
     $html .= '<option value="em" ' . selected($unit, 'em', false) . '>em</option>' . "\n";
     $html .= '</select>' . "\n";
     /* Weights */
     $font_weights = (array) apply_filters('wf_fields_typography_font_weights', array('300' => __('Thin', 'woothemes'), '300 italic' => __('Thin Italic', 'woothemes'), 'normal' => __('Normal', 'woothemes'), 'italic' => __('Italic', 'woothemes'), 'bold' => __('Bold', 'woothemes'), 'bold italic' => __('Bold/Italic', 'woothemes')));
     if (0 < count($font_weights)) {
         $html .= '<select class="woo-typography woo-typography-font-weight woo-typography-style" name="' . esc_attr($key . '[style]') . '" id="' . esc_attr($key . '_style') . '">' . "\n";
         foreach ($font_weights as $k => $v) {
             $html .= '<option value="' . esc_attr($k) . '" ' . selected($value['style'], $k, false) . '>' . esc_html($v) . '</option>' . "\n";
         }
         $html .= '</select>' . "\n";
     }
     /* Font Face */
     $html .= $this->typography_font_face($key, $value);
     /* Border Color */
     $html .= '<input id="' . esc_attr($key . '_color') . '" name="' . esc_attr($key . '[color]') . '" size="40" type="text" class="woo-typography-color colour" value="' . esc_attr($value['color']) . '" />' . "\n";
     $html .= '</span>' . "\n";
     return $html;
 }
Example #12
0
 function shortcode_tag_link($atts, $content)
 {
     $url = home_url('/');
     $target = sanitize_title_with_dashes($content);
     $link = "<a href='{$url}tag/{$target}'>{$content}</a>";
     return $link;
 }
Example #13
0
 function update($id, $values)
 {
     global $wpdb, $frmprodb, $frm_field;
     $new_values = array();
     $values['display_key'] = isset($values['display_key']) ? $values['display_key'] : $values['name'];
     $new_values['display_key'] = FrmAppHelper::get_unique_key($values['display_key'], $frmprodb->displays, 'display_key', $id);
     $new_values['param'] = isset($values['param']) ? sanitize_title_with_dashes($values['param']) : '';
     $fields = array('name', 'description', 'content', 'dyncontent', 'insert_loc', 'type', 'show_count', 'form_id', 'entry_id', 'post_id');
     foreach ($fields as $field) {
         $new_values[$field] = $values[$field];
     }
     $new_values['entry_id'] = isset($values['entry_id']) ? (int) $values['entry_id'] : 0;
     if (isset($values['options'])) {
         $new_values['options'] = array();
         foreach ($values['options'] as $key => $value) {
             $new_values['options'][$key] = $value;
         }
         $new_values['options'] = maybe_serialize($new_values['options']);
     }
     $query_results = $wpdb->update($frmprodb->displays, $new_values, array('id' => $id));
     if ($query_results) {
         wp_cache_delete($id, 'frm_display');
         do_action('frm_update_display', $id, $values);
     }
     return $query_results;
 }
 public static function from_html($html, $title)
 {
     // give us soem breathing room
     ini_set('max_execution_time', 180);
     //$ohtml = $html;
     // pre-parse remote or url based assets
     try {
         $html = self::_pre_parse_remote_assets($html);
     } catch (Exception $e) {
         die('error');
         echo '<h1>Problem parsing html.</h1>';
         echo '<h2>' . force_balance_tags($e->getMessage()) . '</h2>';
         return;
     }
     // if we are debugging the pdf, then depending on the mode, dump the html contents onw
     if (QSOT_DEBUG_PDF & 2) {
         // || ( current_user_can( 'edit_posts' ) && isset( $_GET['as'] ) && 'html' == $_GET['as'] ) ) {
         echo '<pre>';
         echo htmlspecialchars($html);
         echo '</pre>';
         die;
     }
     // include the library
     require_once QSOT::plugin_dir() . 'libs/dompdf/dompdf_config.inc.php';
     // make and output the pdf
     $pdf = new DOMPDF();
     $pdf->load_html($html);
     $pdf->render();
     $pdf->stream(sanitize_title_with_dashes('ticket-' . $title) . '.pdf', array('Attachment' => 1));
     exit;
 }
Example #15
0
 function tlpFmSettingsUpdate()
 {
     global $TLPfoodmenu;
     $error = true;
     if ($TLPfoodmenu->verifyNonce()) {
         $data = array();
         if ($_REQUEST['general']) {
             $general['slug'] = isset($_REQUEST['general']['slug']) ? $_REQUEST['general']['slug'] ? sanitize_title_with_dashes($_REQUEST['general']['slug']) : 'food-menu' : 'food-menu';
             $general['character_limit'] = isset($_REQUEST['general']['character_limit']) ? $_REQUEST['general']['character_limit'] ? intval($_REQUEST['general']['character_limit']) : 150 : 150;
             $general['em_display_col'] = $_REQUEST['general']['em_display_col'] ? esc_attr($_REQUEST['general']['em_display_col']) : 2;
             $general['currency'] = $_REQUEST['general']['currency'] ? esc_attr($_REQUEST['general']['currency']) : null;
             $general['currency_position'] = $_REQUEST['general']['currency_position'] ? esc_attr($_REQUEST['general']['currency_position']) : null;
             $data['general'] = $general;
             $TLPfoodmenu->activate();
         }
         if ($_REQUEST['others']) {
             $others['css'] = $_REQUEST['others']['css'] ? esc_attr($_REQUEST['others']['css']) : null;
             $data['others'] = $others;
         }
         update_option($TLPfoodmenu->options['settings'], $data);
         $error = false;
         $msg = __('Settings successfully updated', TLP_FOOD_MENU_SLUG);
     } else {
         $msg = __('Security Error !!', TLP_FOOD_MENU_SLUG);
     }
     $response = array('error' => $error, 'msg' => $msg);
     wp_send_json($response);
     die;
 }
Example #16
0
 public static function generate($model, $title, $id = null)
 {
     $list = array("job" => array("model" => "Wpjb_Model_Job", "field" => "job_slug"), "type" => array("model" => "Wpjb_Model_JobType", "field" => "slug"), "category" => array("model" => "Wpjb_Model_Category", "field" => "slug"));
     $slug = sanitize_title_with_dashes($title);
     $slug = preg_replace("([^A-z0-9\\-]+)", "", $slug);
     $newSlug = $slug;
     $isUnique = true;
     $query = new Daq_Db_Query();
     $query->select("t." . $list[$model]['field'])->from($list[$model]['model'] . " t")->where("(" . $list[$model]['field'] . " = ?", $newSlug)->orWhere($list[$model]['field'] . " LIKE ? )", $newSlug . "%");
     if ($id > 0) {
         $query->where("id <> ?", $id);
     }
     $field = "t__" . $list[$model]['field'];
     $list = array();
     $c = 0;
     foreach ($query->fetchAll() as $q) {
         $list[] = $q->{$field};
         $c++;
     }
     if ($c > 0) {
         $isUnique = false;
         $i = 1;
         do {
             $i++;
             $newSlug = $slug . "-" . $i;
             if (!in_array($newSlug, $list)) {
                 $isUnique = true;
             }
         } while (!$isUnique);
     }
     return $newSlug;
 }
 /**
  * Creates the Shortcode tag based on the static variables $nspace and $slug
  *
  * @since 4.1
  * @return string
  */
 public function get_shortcode_tag()
 {
     /**
      * Use this hook to filter the tribe namespace on shortcodes
      *
      * @since 4.1
      *
      * @param string Namespace
      * @param string Static Class Name
      * @param object Instance of this class
      */
     $nspace = apply_filters('tribe_events_shortcode_namespace', $this->nspace, __CLASS__, $this);
     // Fetch the Slug
     $slug = $this->get_shortcode_slug();
     $tag = sanitize_title_with_dashes($nspace) . ':' . sanitize_title_with_dashes($slug);
     /**
      * Use this hook to filter the final tag of the Shortcode
      *
      * @since 4.1
      *
      * @param string The complete Tag
      * @param string Static Class Name
      * @param object Instance of this class
      */
     $tag = apply_filters('tribe_events_shortcode_tag', $tag, __CLASS__, $this);
     return $tag;
 }
Example #18
0
 function set_default_options()
 {
     if (!isset($this->date_format)) {
         $this->date_format = 'm/d/Y';
     }
     if (!isset($this->cal_date_format)) {
         $this->cal_date_format = 'mm/dd/yy';
     }
     if (isset($this->theme_nicename)) {
         $this->theme_nicename = sanitize_title_with_dashes($this->theme_name);
     }
     //if(!isset($this->permalinks))
     $this->permalinks = false;
     $settings = $this->default_options();
     foreach ($settings as $setting => $default) {
         if (!isset($this->{$setting})) {
             //set form width at 100% for existing users, but use default for new ones
             if ($setting == 'form_width' and $settings['field_width'] != '100%') {
                 $this->{$setting} = '100%';
             } else {
                 $this->{$setting} = $default;
             }
         }
     }
     $this->line_height = $this->field_height == '' || $this->field_height == 'auto' ? 'normal' : $this->field_height;
 }
Example #19
0
function um_save_custom_user_profile_fields($user_id)
{
    if (!current_user_can('manage_options') || !is_admin() || !isset($_POST['um_role'])) {
        return false;
    }
    update_user_meta($user_id, 'role', sanitize_title_with_dashes($_POST['um_role']));
}
function add_cat_to_db()
{
    global $wpdb, $current_user;
    if ($_REQUEST['action'] == 'add') {
        $category_name = esc_html($_REQUEST['category_name']);
        $category_identifier = $_REQUEST['category_identifier'] == '' ? $category_identifier = sanitize_title_with_dashes($category_name . '-' . time()) : ($category_identifier = sanitize_title_with_dashes($_REQUEST['category_identifier']));
        $category_desc = esc_html($_REQUEST['category_desc']);
        $display_category_desc = $_REQUEST['display_desc'];
        if (!function_exists('espresso_member_data')) {
            $current_user->ID = 1;
        }
        $sql = array('category_name' => $category_name, 'category_identifier' => $category_identifier, 'category_desc' => $category_desc, 'display_desc' => $display_category_desc, 'wp_user' => $current_user->ID);
        $sql_data = array('%s', '%s', '%s', '%s', '%d');
        if ($wpdb->insert(EVENTS_CATEGORY_TABLE, $sql, $sql_data)) {
            ?>
		<div id="message" class="updated fade"><p><strong><?php 
            _e('The category has been added.', 'event_espresso');
            ?>
</strong></p></div>
	<?php 
        } else {
            ?>
		<div id="message" class="error"><p><strong><?php 
            _e('The category   was not saved.', 'event_espresso');
            ?>
 </strong></p></div>

<?php 
        }
    }
}
 public static function after_calendar_template()
 {
     $name = sanitize_title_with_dashes(self::$current_theme->template);
     switch ($name) {
         // core WP themes
         case 'twentytwelve':
         case 'twentythirteen':
             echo '</div></div>';
             break;
         case 'twentyfourteen':
             echo '</div></div></div></div>';
             break;
         case 'twentyfifteen':
             echo '</main></div>';
             break;
             // canvas, OT perferred theme
         // canvas, OT perferred theme
         case 'canvas':
             echo '</section></div></div>';
             break;
             // all other themes
         // all other themes
         default:
             if (has_action('qsot-after-calendar-content-' . $name)) {
                 do_action('qsot-after-calendar-content-' . $name, self::$current_theme);
             } else {
                 echo '</div></div></div></div></div></div>';
             }
             break;
     }
 }
function update_event_category()
{
    global $wpdb;
    $category_id = $_REQUEST['category_id'];
    $category_name = esc_html($_REQUEST['category_name']);
    $category_identifier = $_REQUEST['category_identifier'] == '' ? $category_identifier = sanitize_title_with_dashes($category_name . '-' . time()) : ($category_identifier = sanitize_title_with_dashes($_REQUEST['category_identifier']));
    $category_desc = wp_kses_post($_REQUEST['category_desc']);
    $display_category_desc = $_REQUEST['display_desc'];
    $category_meta['use_pickers'] = isset($_REQUEST['use_pickers']) && !empty($_REQUEST['use_pickers']) ? $_REQUEST['use_pickers'] : '';
    $category_meta['event_background'] = isset($_REQUEST['event_background']) && !empty($_REQUEST['event_background']) ? $_REQUEST['event_background'] : '';
    $category_meta['event_text_color'] = isset($_REQUEST['event_text_color']) && !empty($_REQUEST['event_text_color']) ? $_REQUEST['event_text_color'] : '';
    //echo "<pre>".print_r($_POST,true)."</pre>";
    $category_meta = serialize($category_meta);
    $sql = array('category_name' => $category_name, 'category_identifier' => $category_identifier, 'category_desc' => $category_desc, 'display_desc' => $display_category_desc, 'category_meta' => $category_meta);
    $update_id = array('id' => $category_id);
    $sql_data = array('%s', '%s', '%s', '%s', '%s');
    if ($wpdb->update(EVENTS_CATEGORY_TABLE, $sql, $update_id, $sql_data, array('%d'))) {
        ?>
	<div id="message" class="updated fade"><p><strong><?php 
        _e('The category has been updated.', 'event_espresso');
        ?>
 </strong></p></div>
<?php 
    } else {
        ?>
	<div id="message" class="error"><p><strong><?php 
        _e('The category was not updated.', 'event_espresso');
        ?>
</strong></p></div>

<?php 
    }
}
 /**
  * Callback function for replacing bracketed links with the proper links
  *
  * If a page is found, a link to the page is produced. Otherwise a link to the create page
  * is produced, with the create_title flag.
  *
  * @since 1.2
  *
  * @param array $match A single match passed from preg_replace_callback()
  * @return str A formatted link
  */
 function process_bracket_content($match)
 {
     global $bp, $wpdb;
     // Check for a pipe
     if ($pipe_pos = strpos($match[1], '|')) {
         // If one is found, then the link text will be different from
         // the page name
         $link_text = substr($match[1], $pipe_pos + 1);
         $link_page = substr($match[1], 0, $pipe_pos);
     } else {
         // If no pipe is found, set the link text and link page the same
         $link_text = $link_page = $match[1];
     }
     // Look for a page with this title. WP_Query does not allow this for some reason
     $docs = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE post_title = %s AND post_type = %s {$in_clause}", $link_page, bp_docs_get_post_type_name()));
     // If none were found, do the same query with page slugs
     if (empty($docs)) {
         $docs = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE post_name = %s AND post_type = %s {$in_clause}", sanitize_title_with_dashes($link_page), bp_docs_get_post_type_name()));
     }
     // Filter the docs. This will be used to exclude docs that do not belong to a group
     $docs = apply_filters('bp_docs_bracket_matches', $docs);
     if (!empty($docs)) {
         // If we have a result, create a link to that page
         // There might be more than one result. I guess we take the first one
         $doc = $docs[0];
         $permalink = get_permalink($doc);
         $class = 'existing-doc';
     } else {
         // If no result is found, create a link to the edit page
         $permalink = add_query_arg('create_title', urlencode($link_page), bp_docs_get_create_link());
         $class = 'nonexistent-doc';
     }
     return apply_filters('bp_docs_bracket_link', '<a href="' . $permalink . '" class="' . $class . '">' . $link_text . '</a>');
 }
Example #24
0
 /**
  * BackWPup_Message_Box constructor.
  *
  * @param string $box_id Name for box to have more than one or future one
  */
 public function __construct($box_id)
 {
     if (!$box_id || !is_string($box_id)) {
         return null;
     }
     $this->box_id = sanitize_title_with_dashes($box_id);
 }
 /**
  * Save community role
  */
 public function community_role_save($user_id)
 {
     if (current_user_can('edit_user', $user_id) && isset($_POST['um_role'])) {
         update_user_meta($user_id, 'role', sanitize_title_with_dashes($_POST['um_role']));
         delete_option("um_cache_userdata_{$user_id}");
     }
 }
 function prepare_items()
 {
     include ABSPATH . 'wp-admin/includes/plugin-install.php';
     global $tabs, $tab, $paged, $type, $term;
     wp_reset_vars(array('tab'));
     $paged = $this->get_pagenum();
     $per_page = 30;
     // These are the tabs which are shown on the page
     $tabs = array();
     $tabs['dashboard'] = __('Search');
     if ('search' == $tab) {
         $tabs['search'] = __('Search Results');
     }
     $tabs['featured'] = _x('Featured', 'Plugin Installer');
     $tabs['popular'] = _x('Popular', 'Plugin Installer');
     $tabs['new'] = _x('Newest', 'Plugin Installer');
     $nonmenu_tabs = array('plugin-information');
     //Valid actions to perform which do not have a Menu item.
     $tabs = apply_filters('install_plugins_tabs', $tabs);
     $nonmenu_tabs = apply_filters('install_plugins_nonmenu_tabs', $nonmenu_tabs);
     // If a non-valid menu tab has been selected, And its not a non-menu action.
     if (empty($tab) || !isset($tabs[$tab]) && !in_array($tab, (array) $nonmenu_tabs)) {
         $tab = key($tabs);
     }
     $args = array('page' => $paged, 'per_page' => $per_page);
     switch ($tab) {
         case 'search':
             $type = isset($_REQUEST['type']) ? stripslashes($_REQUEST['type']) : 'term';
             $term = isset($_REQUEST['s']) ? stripslashes($_REQUEST['s']) : '';
             switch ($type) {
                 case 'tag':
                     $args['tag'] = sanitize_title_with_dashes($term);
                     break;
                 case 'term':
                     $args['search'] = $term;
                     break;
                 case 'author':
                     $args['author'] = $term;
                     break;
             }
             add_action('install_plugins_table_header', 'install_search_form', 10, 0);
             break;
         case 'featured':
         case 'popular':
         case 'new':
             $args['browse'] = $tab;
             break;
         default:
             $args = false;
     }
     if (!$args) {
         return;
     }
     $api = plugins_api('query_plugins', $args);
     if (is_wp_error($api)) {
         wp_die($api->get_error_message() . '</p> <p class="hide-if-no-js"><a href="#" onclick="document.location.reload(); return false;">' . __('Try again') . '</a>');
     }
     $this->items = $api->plugins;
     $this->set_pagination_args(array('total_items' => $api->info['results'], 'per_page' => $per_page));
 }
Example #27
0
function tom_validate_create_options($input)
{
    /* If have value from new group */
    if (!empty($input['new-group']['name'])) {
        $idFromName = sanitize_title_with_dashes($input['new-group']['name']);
        $input[$idFromName]['name'] = $input['new-group']['name'];
        $input[$idFromName]['type'] = 'heading';
        $input[$idFromName]['desc'] = $input['new-group']['desc'];
        unset($input['new-group']);
    } else {
        if (isset($input['new-group'])) {
            unset($input['new-group']);
        }
    }
    $value['options'] = array();
    $haveoptions = array();
    /* Parse input options */
    foreach ($input as $key => $value) {
        if (!empty($value['options'])) {
            /* combine input value key and input value to one array as key => value */
            $combine[$key]['options'] = array_combine($value['options']['opt-key'], $value['options']['opt-val']);
            /* get other field like name, type */
            $org[$key] = $value;
            /* Merge options field */
            $haveoptions[$key] = array_merge($org[$key], $combine[$key]);
        }
        $input = array_merge($input, $haveoptions);
    }
    /* Merge with main input */
    $input = array_merge($input, $haveoptions);
    return json_encode($input);
}
function add_cat_to_db()
{
    global $wpdb, $current_user;
    if ($_REQUEST['action'] == 'add') {
        $category_name = isset($_REQUEST['category_name']) && !empty($_REQUEST['category_name']) ? esc_html($_REQUEST['category_name']) : '';
        $category_identifier = isset($_REQUEST['category_identifier']) && !empty($_REQUEST['category_identifier']) ? $category_identifier = sanitize_title_with_dashes($_REQUEST['category_identifier']) : ($category_identifier = sanitize_title_with_dashes($category_name . '-' . time()));
        $category_desc = isset($_REQUEST['category_desc']) && !empty($_REQUEST['category_desc']) ? wp_kses_post($_REQUEST['category_desc']) : '';
        $display_category_desc = isset($_REQUEST['display_desc']) && !empty($_REQUEST['display_desc']) ? $_REQUEST['display_desc'] : '';
        if (!function_exists('espresso_member_data')) {
            $current_user->ID = 1;
        }
        $category_meta['use_pickers'] = isset($_REQUEST['use_pickers']) && !empty($_REQUEST['use_pickers']) ? $_REQUEST['use_pickers'] : '';
        $category_meta['event_background'] = isset($_REQUEST['event_background']) && !empty($_REQUEST['event_background']) ? $_REQUEST['event_background'] : '';
        $category_meta['event_text_color'] = isset($_REQUEST['event_text_color']) && !empty($_REQUEST['event_text_color']) ? $_REQUEST['event_text_color'] : '';
        $category_meta = serialize($category_meta);
        $sql = array('category_name' => $category_name, 'category_identifier' => $category_identifier, 'category_desc' => $category_desc, 'display_desc' => $display_category_desc, 'category_meta' => $category_meta, 'wp_user' => $current_user->ID);
        $sql_data = array('%s', '%s', '%s', '%s', '%s', '%d');
        if ($wpdb->insert(EVENTS_CATEGORY_TABLE, $sql, $sql_data)) {
            ?>
		<div id="message" class="updated fade"><p><strong><?php 
            _e('The category has been added.', 'event_espresso');
            ?>
</strong></p></div>
	<?php 
        } else {
            ?>
		<div id="message" class="error"><p><strong><?php 
            _e('The category   was not saved.', 'event_espresso');
            ?>
 </strong></p></div>

<?php 
        }
    }
}
function update_event_category()
{
    global $wpdb;
    $category_id = $_REQUEST['category_id'];
    $category_name = esc_html($_REQUEST['category_name']);
    $category_identifier = $_REQUEST['category_identifier'] == '' ? $category_identifier = sanitize_title_with_dashes($category_name . '-' . time()) : ($category_identifier = sanitize_title_with_dashes($_REQUEST['category_identifier']));
    $category_desc = esc_html($_REQUEST['category_desc']);
    $display_category_desc = $_REQUEST['display_desc'];
    $sql = array('category_name' => $category_name, 'category_identifier' => $category_identifier, 'category_desc' => $category_desc, 'display_desc' => $display_category_desc);
    $update_id = array('id' => $category_id);
    $sql_data = array('%s', '%s', '%s', '%s');
    if ($wpdb->update(EVENTS_CATEGORY_TABLE, $sql, $update_id, $sql_data, array('%d'))) {
        ?>
	<div id="message" class="updated fade"><p><strong><?php 
        _e('The category has been updated.', 'event_espresso');
        ?>
 </strong></p></div>
<?php 
    } else {
        ?>
	<div id="message" class="error"><p><strong><?php 
        _e('The category was not updated.', 'event_espresso');
        ?>
</strong></p></div>

<?php 
    }
}
Example #30
0
 /**
  * Create the Custom Post Type.
  *
  * @param string $type Name of the posttype.
  * @param string $singular_label CPT Name in singular form.
  * @param string $plural_label CPT Name in plural form.
  * @param mixed $settings Custom user settings to override default CPT values.
  */
 public function make($type, $singular_label, $plural_label, $settings = array())
 {
     // Define the default settings
     $default_settings = array('labels' => array('name' => __($plural_label, $this->textdomain), 'singular_name' => __($singular_label, $this->textdomain), 'add_new_item' => __('Add New ' . $singular_label, $this->textdomain), 'edit_item' => __('Edit ' . $singular_label, $this->textdomain), 'new_item' => __('New ' . $singular_label, $this->textdomain), 'view_item' => __('View ' . $singular_label, $this->textdomain), 'search_items' => __('Search ' . $plural_label, $this->textdomain), 'not_found' => __('No ' . $plural_label . ' found', $this->textdomain), 'not_found_in_trash' => __('No ' . $plural_label . ' found in trash', $this->textdomain), 'parent_item_colon' => __('Parent ' . $singular_label, $this->textdomain)), 'public' => true, 'has_archive' => true, 'menu_position' => 20, 'menu_icon' => 'dashicons-admin-post', 'supports' => array('title', 'editor', 'thumbnail'), 'rewrite' => array('slug' => sanitize_title_with_dashes($plural_label)));
     // Override any settings provided by user and store the settings with the posts array.
     $this->posts[$type] = array_merge($default_settings, $settings);
 }