コード例 #1
0
 static function show_staff_directory($param = null, $template = NULL)
 {
     parse_str($param);
     global $wpdb;
     // make sure we aren't calling both id and cat at the same time
     if (isset($id) && $id != '' && isset($cat) && $cat != '') {
         return "<strong>ERROR: You cannot set both a single ID and a category ID for your Staff Directory</strong>";
     }
     $query_args = array('post_type' => 'staff', 'posts_per_page' => -1);
     // check if it's a single staff member first, since single members won't be ordered
     if (isset($id) && $id != '' && (!isset($cat) || $cat == '')) {
         $query_args['p'] = $id;
     }
     // ends single staff
     // check if we're returning a staff category
     if (isset($cat) && $cat != '' && (!isset($id) || $id == '')) {
         $query_args['tax_query'] = array(array('taxonomy' => 'staff_category', 'terms' => array($cat)));
     }
     if (isset($orderby) && $orderby != '') {
         $query_args['orderby'] = $orderby;
     }
     if (isset($order) && $order != '') {
         $query_args['order'] = $order;
     }
     $staff_query = new WP_Query($query_args);
     switch ($template) {
         case 'list':
             $output = StaffDirectoryShortcode::html_for_list_template($staff_query);
             break;
         case 'grid':
             $output = StaffDirectoryShortcode::html_for_grid_template($staff_query);
             break;
         case 'category':
             $output = StaffDirectoryShortcode::html_for_category_template($query_args);
             break;
         default:
             $output = StaffDirectoryShortcode::html_for_custom_template($template, $staff_query);
             break;
     }
     wp_reset_query();
     return $output;
 }
コード例 #2
0
<?php

/*
Plugin Name: Staff Directory
Plugin URI: https://wordpress.org/plugins/staff-directory/
Description: Allows Wordpress to keep track of your staff directory for your website. Good for churches, small companies, etc.
Version: 1.0.1
Author: Adam Tootle
Author URI: http://www.adamtootle.com
*/
global $wpdb;
$staff_directory_table = $wpdb->prefix . 'staff_directory';
define('STAFF_DIRECTORY_TABLE', $wpdb->prefix . 'staff_directory');
define('STAFF_TEMPLATES', $wpdb->prefix . 'staff_directory_templates');
define('STAFF_PHOTOS_DIRECTORY', WP_CONTENT_DIR . "/uploads/staff-photos/");
require_once dirname(__FILE__) . '/classes/staff_settings.php';
StaffSettings::setupDefaults();
require_once dirname(__FILE__) . '/classes/staff_directory.php';
require_once dirname(__FILE__) . '/classes/staff_directory_shortcode.php';
require_once dirname(__FILE__) . '/classes/staff_directory_admin.php';
StaffDirectory::register_post_types();
StaffDirectory::set_default_meta_fields_if_necessary();
StaffDirectoryAdmin::register_admin_menu_items();
StaffDirectoryShortcode::register_shortcode();
if (StaffDirectory::show_import_message()) {
    StaffDirectoryAdmin::register_import_old_staff_message();
}
register_activation_hook(__FILE__, array('StaffDirectory', 'set_default_templates_if_necessary'));