当前位置: 首页>>代码示例>>PHP>>正文


PHP sp_array_value函数代码示例

本文整理汇总了PHP中sp_array_value函数的典型用法代码示例。如果您正苦于以下问题:PHP sp_array_value函数的具体用法?PHP sp_array_value怎么用?PHP sp_array_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sp_array_value函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_players

 /**
  * Get players.
  */
 public function get_players()
 {
     check_ajax_referer('sp-get-players', 'nonce');
     $team = sp_array_value($_POST, 'team');
     $league = sp_array_value($_POST, 'league');
     $season = sp_array_value($_POST, 'season');
     $index = sp_array_value($_POST, 'index', 1);
     $selected = sp_array_value($_POST, 'selected', array());
     $args = array('orderby' => 'menu_order');
     if ($team) {
         $args['meta_query'] = array(array('key' => 'sp_current_team', 'value' => sp_array_value($_POST, 'team')));
     }
     if ($league || $season) {
         $args['tax_query'] = array('relation' => 'AND');
         if ($league) {
             $args['tax_query'][] = array('taxonomy' => 'sp_league', 'field' => 'id', 'terms' => $league);
         }
         if ($season) {
             $args['tax_query'][] = array('taxonomy' => 'sp_season', 'field' => 'id', 'terms' => $season);
         }
     }
     $player_args = $args;
     $player_args['meta_key'] = 'sp_number';
     $player_args['orderby'] = 'meta_value_num';
     $player_args['order'] = 'ASC';
     $players = sp_get_posts('sp_player', $player_args);
     $staff = sp_get_posts('sp_staff', $args);
     $data = array('index' => $index);
     foreach ($players as $key => $value) {
         $players[$key]->post_title = sp_get_player_name_with_number($value->ID);
     }
     $data['players'] = $players;
     $data['staff'] = $staff;
     wp_send_json_success($data);
 }
开发者ID:mttcmrn,项目名称:Suffield-Bruins-WP,代码行数:38,代码来源:sportspress-lazy-loading.php

示例2: custom_columns

 /**
  * Define our custom columns shown in admin.
  * @param  string $column
  */
 public function custom_columns($column, $post_id)
 {
     switch ($column) {
         case 'sp_player':
             $players = array_filter(get_post_meta($post_id, 'sp_player'));
             echo sizeof($players);
             break;
         case 'sp_league':
             echo get_the_terms($post_id, 'sp_league') ? the_terms($post_id, 'sp_league') : __('All', 'prosports');
             break;
         case 'sp_season':
             echo get_the_terms($post_id, 'sp_season') ? the_terms($post_id, 'sp_season') : __('All', 'prosports');
             break;
         case 'sp_team':
             $teams = (array) get_post_meta($post_id, 'sp_team', false);
             $teams = array_filter($teams);
             if (empty($teams)) {
                 echo __('All', 'prosports');
             } else {
                 foreach ($teams as $team_id) {
                     if (!$team_id) {
                         continue;
                     }
                     $team = get_post($team_id);
                     if ($team) {
                         echo $team->post_title . '<br>';
                     }
                 }
             }
             break;
         case 'sp_layout':
             echo sp_array_value(SP()->formats->list, get_post_meta($post_id, 'sp_format', true), '&mdash;');
             break;
     }
 }
开发者ID:kleitz,项目名称:ProSports,代码行数:39,代码来源:class-sp-admin-cpt-list.php

示例3: import

        /**
         * import function.
         *
         * @access public
         * @param array $array
         * @param array $columns
         * @return void
         */
        function import($array = array(), $columns = array('post_title'))
        {
            $this->imported = $this->skipped = 0;
            if (!is_array($array) || !sizeof($array)) {
                $this->footer();
                die;
            }
            $rows = array_chunk($array, sizeof($columns));
            foreach ($rows as $row) {
                $row = array_filter($row);
                if (empty($row)) {
                    continue;
                }
                $meta = array();
                foreach ($columns as $index => $key) {
                    $meta[$key] = sp_array_value($row, $index);
                }
                $name = sp_array_value($meta, 'post_title');
                if (!$name) {
                    $this->skipped++;
                    continue;
                }
                $args = array('post_type' => 'sp_sponsor', 'post_status' => 'publish', 'post_title' => $name);
                $id = wp_insert_post($args);
                // Update URL
                update_post_meta($id, 'sp_url', sp_array_value($meta, 'sp_url'));
                $this->imported++;
            }
            // Show Result
            echo '<div class="updated settings-error below-h2"><p>
				' . sprintf(__('Import complete - imported <strong>%s</strong> sponsors and skipped <strong>%s</strong>.', 'prosports'), $this->imported, $this->skipped) . '
			</p></div>';
            $this->import_end();
        }
开发者ID:kleitz,项目名称:ProSports,代码行数:42,代码来源:class-sp-sponsor-importer.php

示例4: output

    /**
     * Output the metabox
     */
    public static function output($post)
    {
        $feeds = new SP_Feeds();
        $calendar_feeds = $feeds->calendar;
        ?>
		<div>
			<?php 
        foreach ($calendar_feeds as $slug => $formats) {
            ?>
				<?php 
            $link = add_query_arg('feed', 'sp-' . $slug, untrailingslashit(get_post_permalink($post)));
            ?>
				<?php 
            foreach ($formats as $format) {
                ?>
					<?php 
                $protocol = sp_array_value($format, 'protocol');
                if ($protocol) {
                    $feed = str_replace(array('http:', 'https:'), 'webcal:', $link);
                } else {
                    $feed = $link;
                }
                $prefix = sp_array_value($format, 'prefix');
                if ($prefix) {
                    $feed = $prefix . urlencode($feed);
                }
                ?>
					<p>
						<strong><?php 
                echo sp_array_value($format, 'name');
                ?>
</strong>
						<a class="sp-link" href="<?php 
                echo $feed;
                ?>
" target="_blank" title="<?php 
                _e('Link', 'sportspress');
                ?>
"></a>
					</p>
					<p>
						<input type="text" value="<?php 
                echo $feed;
                ?>
" readonly="readonly" class="code widefat">
					</p>
				<?php 
            }
            ?>
			<?php 
        }
        ?>
		</div>
		<?php 
    }
开发者ID:engrmostafijur,项目名称:SportsPress,代码行数:58,代码来源:class-sp-meta-box-calendar-feeds.php

示例5: save

 /**
  * Save settings
  */
 public function save()
 {
     $settings = $this->get_settings();
     SP_Admin_Settings::save_fields($settings);
     update_option('sportspress_header_sponsor_width', (int) sp_array_value($_POST, 'sportspress_header_sponsor_width', 128));
     update_option('sportspress_header_sponsor_height', (int) sp_array_value($_POST, 'sportspress_header_sponsor_height', 64));
     update_option('sportspress_header_sponsors_top', (int) sp_array_value($_POST, 'sportspress_header_sponsors_top', 10));
     update_option('sportspress_header_sponsors_right', (int) sp_array_value($_POST, 'sportspress_header_sponsors_right', 10));
     update_option('sportspress_footer_sponsor_width', (int) sp_array_value($_POST, 'sportspress_footer_sponsor_width', 256));
     update_option('sportspress_footer_sponsor_height', (int) sp_array_value($_POST, 'sportspress_footer_sponsor_height', 128));
 }
开发者ID:mttcmrn,项目名称:Suffield-Bruins-WP,代码行数:14,代码来源:class-sp-settings-sponsors.php

示例6: save_inline_results

 /**
  * Save event results inline.
  *
  * @since  1.5
  */
 function save_inline_results()
 {
     check_ajax_referer('sp-save-inline-results', 'nonce');
     $id = sp_array_value($_POST, 'post_id');
     $results = sp_array_value($_POST, 'results');
     if (sp_update_main_results($id, $results)) {
         wp_send_json_success();
     } else {
         wp_send_json_error();
     }
 }
开发者ID:engrmostafijur,项目名称:SportsPress,代码行数:16,代码来源:class-sp-admin-ajax.php

示例7: save

 /**
  * Save meta box data
  */
 public static function save($post_id, $post)
 {
     update_post_meta($post_id, 'sp_minutes', sp_array_value($_POST, 'sp_minutes', get_option('sportspress_event_minutes', 90)));
     $venues = array_filter(sp_array_value(sp_array_value($_POST, 'tax_input', array()), 'sp_venue', array()));
     if (empty($venues)) {
         $teams = sp_array_value($_POST, 'sp_team', array());
         $team = reset($teams);
         $venue = sp_get_the_term_id($team, 'sp_venue');
         wp_set_post_terms($post_id, $venue, 'sp_venue');
     }
 }
开发者ID:engrmostafijur,项目名称:SportsPress,代码行数:14,代码来源:class-sp-meta-box-event-details.php

示例8: wp_insert_post_data

 /**
  * Auto-generate an event title based on the team playing if left blank.
  *
  * @param array $data
  * @return array
  */
 public function wp_insert_post_data($data, $postarr)
 {
     if ($data['post_type'] == 'sp_event' && $data['post_title'] == '') {
         $teams = sp_array_value($postarr, 'sp_team', array());
         $team_names = array();
         foreach ($teams as $team) {
             $team_names[] = get_the_title($team);
         }
         $data['post_title'] = implode(' ' . get_option('prosports_event_teams_delimiter', 'vs') . ' ', $team_names);
     }
     return $data;
 }
开发者ID:kleitz,项目名称:ProSports,代码行数:18,代码来源:class-sp-admin-cpt-event.php

示例9: get_settings

 /**
  * Get settings array
  *
  * @return array
  */
 public function get_settings()
 {
     $settings = array(array('title' => __('Text', 'prosports'), 'type' => 'title', 'desc' => __('The following options affect how words are displayed on the frontend.', 'prosports'), 'id' => 'text_options'));
     $strings = sp_get_text_options();
     $options = get_option('prosports_text');
     foreach ($strings as $string) {
         $settings[] = array('title' => $string, 'id' => 'prosports_text[' . $string . ']', 'default' => '', 'placeholder' => $string, 'value' => sp_array_value($options, $string, null), 'type' => 'text');
     }
     $settings[] = array('type' => 'sectionend', 'id' => 'text_options');
     return apply_filters('prosports_text_settings', $settings);
     // End event settings
 }
开发者ID:kleitz,项目名称:ProSports,代码行数:17,代码来源:class-sp-settings-text.php

示例10: add_venue_fields

    /**
     * Add venue fields.
     *
     * @access public
     * @return void
     */
    public function add_venue_fields()
    {
        $args = array('orderby' => 'id', 'order' => 'DESC', 'hide_empty' => false, 'number' => 1);
        // Get latitude and longitude from the last added venue
        $terms = get_terms('sp_venue', $args);
        if ($terms && array_key_exists(0, $terms) && is_object(reset($terms))) {
            $term = reset($terms);
            $t_id = $term->term_id;
            $term_meta = get_option("taxonomy_{$t_id}");
            $latitude = sp_array_value($term_meta, 'sp_latitude', '40.7324319');
            $longitude = sp_array_value($term_meta, 'sp_longitude', '-73.82480799999996');
        } else {
            $latitude = '40.7324319';
            $longitude = '-73.82480799999996';
        }
        ?>
		<div class="form-field">
			<label for="term_meta[sp_address]"><?php 
        _e('Address', 'sportspress');
        ?>
</label>
			<input type="text" class="sp-address" name="term_meta[sp_address]" id="term_meta[sp_address]" value="">
			<p><div class="sp-location-picker"></div></p>
			<p><?php 
        _e("Drag the marker to the venue's location.", 'sportspress');
        ?>
</p>
		</div>
		<div class="form-field">
			<label for="term_meta[sp_latitude]"><?php 
        _e('Latitude', 'sportspress');
        ?>
</label>
			<input type="text" class="sp-latitude" name="term_meta[sp_latitude]" id="term_meta[sp_latitude]" value="<?php 
        echo esc_attr($latitude);
        ?>
">
		</div>
		<div class="form-field">
			<label for="term_meta[sp_longitude]"><?php 
        _e('Longitude', 'sportspress');
        ?>
</label>
			<input type="text" class="sp-longitude" name="term_meta[sp_longitude]" id="term_meta[sp_longitude]" value="<?php 
        echo esc_attr($longitude);
        ?>
">
		</div>
	<?php 
    }
开发者ID:jpurpleman,项目名称:SportsPress,代码行数:56,代码来源:class-sp-admin-taxonomies.php

示例11: save

 /**
  * Save meta box data
  */
 public static function save($post_id, $post)
 {
     update_post_meta($post_id, 'sp_minutes', sp_array_value($_POST, 'sp_minutes', get_option('prosports_event_minutes', 90)));
     $taxonomies = apply_filters('prosports_event_taxonomies', array('sp_league' => null, 'sp_season' => null, 'sp_venue' => 'sp_event'));
     foreach ($taxonomies as $taxonomy => $post_type) {
         $value = sp_array_value($_POST, $taxonomy, -1);
         if (0 == $value) {
             $teams = sp_array_value($_POST, 'sp_team', array());
             $team = reset($teams);
             $value = sp_get_the_term_id($team, $taxonomy);
         }
         wp_set_post_terms($post_id, $value, $taxonomy);
         update_post_meta($post_id, $taxonomy, $value);
     }
 }
开发者ID:kleitz,项目名称:ProSports,代码行数:18,代码来源:class-sp-meta-box-event-details.php

示例12: custom_columns

 /**
  * Define our custom columns shown in admin.
  * @param  string $column
  */
 public function custom_columns($column, $post_id)
 {
     switch ($column) {
         case 'sp_league':
             echo get_the_terms($post_id, 'sp_league') ? the_terms($post_id, 'sp_league') : __('All', 'sportspress');
             break;
         case 'sp_season':
             echo get_the_terms($post_id, 'sp_season') ? the_terms($post_id, 'sp_season') : __('All', 'sportspress');
             break;
         case 'sp_rounds':
             echo get_post_meta($post_id, 'sp_rounds', true);
             break;
         case 'sp_layout':
             echo sp_array_value(SP()->formats->tournament, get_post_meta($post_id, 'sp_format', true), '&mdash;');
             break;
     }
 }
开发者ID:mttcmrn,项目名称:Suffield-Bruins-WP,代码行数:21,代码来源:class-sp-admin-cpt-tournament.php

示例13: delete_duplicate

 public static function delete_duplicate(&$post)
 {
     global $wpdb;
     $key = isset($post['sp_key']) ? $post['sp_key'] : null;
     if (!$key) {
         $key = $post['post_title'];
     }
     $id = sp_array_value($post, 'post_ID', 'var');
     $title = sp_get_eos_safe_slug($key, $id);
     $check_sql = "SELECT ID FROM {$wpdb->posts} WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
     $post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $title, $post['post_type'], $id));
     if ($post_name_check) {
         wp_delete_post($post_name_check, true);
         $post['post_status'] = 'draft';
     }
     return $post_name_check;
 }
开发者ID:kleitz,项目名称:ProSports,代码行数:17,代码来源:class-sp-meta-box-config.php

示例14: import

        /**
         * import function.
         *
         * @access public
         * @param array $array
         * @param array $columns
         * @return void
         */
        function import($array = array(), $columns = array('post_title'))
        {
            $this->imported = $this->skipped = 0;
            if (!is_array($array) || !sizeof($array)) {
                $this->footer();
                die;
            }
            $rows = array_chunk($array, sizeof($columns));
            foreach ($rows as $row) {
                $row = array_filter($row);
                if (empty($row)) {
                    continue;
                }
                $meta = array();
                foreach ($columns as $index => $key) {
                    $meta[$key] = sp_array_value($row, $index);
                }
                $name = sp_array_value($meta, 'post_title');
                if (!$name) {
                    $this->skipped++;
                    continue;
                }
                $args = array('post_type' => 'sp_team', 'post_status' => 'publish', 'post_title' => $name);
                $id = wp_insert_post($args);
                // Flag as import
                update_post_meta($id, '_sp_import', 1);
                // Update leagues
                $leagues = explode('|', sp_array_value($meta, 'sp_league'));
                wp_set_object_terms($id, $leagues, 'sp_league', false);
                // Update seasons
                $seasons = explode('|', sp_array_value($meta, 'sp_season'));
                wp_set_object_terms($id, $seasons, 'sp_season', false);
                // Update venues
                $venues = explode('|', sp_array_value($meta, 'sp_venue'));
                wp_set_object_terms($id, $venues, 'sp_venue', false);
                // Update meta
                update_post_meta($id, 'sp_url', sp_array_value($meta, 'sp_url'));
                update_post_meta($id, 'sp_abbreviation', sp_array_value($meta, 'sp_abbreviation'));
                $this->imported++;
            }
            // Show Result
            echo '<div class="updated settings-error below-h2"><p>
				' . sprintf(__('Import complete - imported <strong>%s</strong> teams and skipped <strong>%s</strong>.', 'sportspress'), $this->imported, $this->skipped) . '
			</p></div>';
            $this->import_end();
        }
开发者ID:perren,项目名称:SportsPress,代码行数:54,代码来源:class-sp-team-importer.php

示例15: wp_insert_post_data

 /**
  * Auto-generate an event title based on the team playing if left blank.
  *
  * @param array $data
  * @return array
  */
 public function wp_insert_post_data($data, $postarr)
 {
     if ($data['post_type'] == 'sp_event' && $data['post_title'] == '') {
         $teams = sp_array_value($postarr, 'sp_team', array());
         $teams = array_filter($teams);
         $team_names = array();
         foreach ($teams as $team) {
             while (is_array($team)) {
                 $team = array_shift(array_filter($team));
             }
             if ($team > 0) {
                 $team_names[] = get_the_title($team);
             }
         }
         $team_names = array_unique($team_names);
         $data['post_title'] = implode(' ' . get_option('sportspress_event_teams_delimiter', 'vs') . ' ', $team_names);
     }
     return $data;
 }
开发者ID:perren,项目名称:SportsPress,代码行数:25,代码来源:class-sp-admin-cpt-event.php


注:本文中的sp_array_value函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。