diff --git a/load-staffer.php b/load-staffer.php
index f609447..1318293 100644
--- a/load-staffer.php
+++ b/load-staffer.php
@@ -12,170 +12,271 @@
// loads language pack
function staffer_load_textdomain() {
- load_plugin_textdomain( 'staffer', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
+ load_plugin_textdomain( 'staffer', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
+
add_action( 'init', 'staffer_load_textdomain' );
// staffer init
-function staffer_init(){
- if (delete_transient('staffer_flush_rules')) {
- flush_rewrite_rules();
- }
+function staffer_init() {
+ if ( delete_transient( 'staffer_flush_rules' ) ) {
+ flush_rewrite_rules();
+ }
register_setting( 'staffer_options', 'staffer', 'staffer_validate' );
}
-add_action('admin_init', 'staffer_init' );
+
+add_action( 'admin_init', 'staffer_init' );
// adds menu page
function staffer_add_page() {
- add_options_page('Staffer Options', 'Staffer Options', 'manage_options', 'staffer', 'staffer_do_page');
+ add_options_page( 'Staffer Options', 'Staffer Options', 'manage_options', 'staffer', 'staffer_do_page' );
}
-add_action('admin_menu', 'staffer_add_page');
+
+add_action( 'admin_menu', 'staffer_add_page' );
// writes the menu page
function staffer_do_page() {
$supportsite = 'https://www.edwardrjenkins.com';
- echo '
';
- _e('For paid support or customizations, please contact me at', 'staffer' );
- echo ' edwardrjenkins.com ';
- echo ' ';
- ?>
-
-
-
+
+
+
+
+
+
+
+
+
+ _x( 'Departments', 'taxonomy general name', 'staffer' ),
- 'singular_name' => _x( 'Department', 'taxonomy singular name', 'staffer' ),
- 'search_items' => __( 'Search Departments', 'staffer' ),
- 'all_items' => __( 'All Departments', 'staffer' ),
- 'parent_item' => __( 'Parent Department', 'staffer' ),
- 'parent_item_colon' => __( 'Parent Department:', 'staffer' ),
- 'edit_item' => __( 'Edit Department', 'staffer' ),
- 'update_item' => __( 'Update Department', 'staffer' ),
- 'add_new_item' => __( 'Add New Department', 'staffer' ),
- 'new_item_name' => __( 'New Department Name', 'staffer' ),
- 'menu_name' => __( 'Departments', 'staffer' ),
- );
-
register_taxonomy(
'department',
'staff',
array(
'hierarchical' => true,
- 'labels' => $department_labels,
- 'rewrite' => array( 'slug' => $taxslug, 'hierarchical' => true),
+ 'label' => __( 'Departments' ),
+ 'rewrite' => array( 'slug' => $taxslug, 'hierarchical' => true ),
'query_var' => 'department',
- 'public' => true,
- 'show_admin_column' => true,
+ 'public' => true,
)
);
- }
-add_action ('init', 'staffer_taxonomy');
+}
+
+add_action( 'init', 'staffer_taxonomy' );
// custom post type for staff
function create_staff_cpt_staffer() {
- $stafferoptions = get_option ('staffer');
- $stafferslug = $stafferoptions['slug'];
+ $stafferoptions = get_option( 'staffer' );
+ $stafferslug = $stafferoptions['slug'];
// fixes title tag issue and adds label option
- if ( !empty ($stafferoptions['label'] ) ) {
+ if ( ! empty ( $stafferoptions['label'] ) ) {
$stafferlabel = $stafferoptions['label'];
} else {
$stafferlabel = 'Staff';
}
$rewrite = array(
- 'slug' => $stafferslug,
- 'with_front' => (bool) apply_filters( 'staffer_with_front', true ),
- 'pages' => true,
- 'feeds' => true,
+ 'slug' => $stafferslug,
+ 'with_front' => true,
+ 'pages' => true,
+ 'feeds' => true,
);
if ( isset( $stafferoptions['manual_mode'] ) ) {
@@ -234,155 +321,313 @@ function create_staff_cpt_staffer() {
} else {
$archive = true;
}
- register_post_type('staff', array(
- 'labels' => array(
- 'name' => $stafferlabel,
- 'taxonomy' => 'department',
- 'singular_name' => __( 'Staff Member', 'staffer' ),
- 'add_new_item' => __( 'Add New Staff Member', 'staffer' ),
- 'edit_item' => __( 'Edit Staff Member', 'staffer' ),
- 'new_item' => __( 'New Staff Member', 'staffer' ),
- 'all_items' => __( 'All Staff Members', 'staffer' ),
- 'view_item' => __( 'View Staff Member', 'staffer' ),
- 'search_items' => __( 'Search Staff Members', 'staffer' ),
- 'not_found' => __( 'No Staff Members Found', 'staffer' ),
- 'not_found_in_trash' => __( 'No Staff Members in Trash', 'staffer' ),
+ register_post_type( 'staff', array(
+ 'labels' => array(
+ 'name' => $stafferlabel,
+ // future release 'taxonomy' => 'department',
+ 'singular_name' => __( 'Staff Member' ),
+ 'add_new_item' => __( 'Add New Staff Member' ),
+ 'edit_item' => 'Edit Staff Member',
+ 'new_item' => 'New Staff Member',
+ 'all_items' => 'All Staff Members',
+ 'view_item' => 'View Staff Member',
+ 'search_items' => 'Search Staff Members',
+ 'not_found' => 'No Staff Members Found',
+ 'not_found_in_trash' => 'No Staff Members in Trash',
),
- 'public' => true,
- 'has_archive' => $archive,
+ 'public' => true,
+ 'has_archive' => $archive,
'show_in_menu' => true,
- 'menu_order' => '4',
- 'rewrite' => $rewrite,
- 'menu_icon' => 'dashicons-id',
- 'supports' => array(
+ 'menu_order' => '4',
+ 'rewrite' => $rewrite,
+ 'menu_icon' => 'dashicons-id',
+ 'supports' => array(
'title',
'editor',
'revisions',
+ 'custom-fields',
'thumbnail',
'excerpt'
- )
)
- );
+ ) );
}
-add_action ('init', 'create_staff_cpt_staffer' );
+
+add_action( 'init', 'create_staff_cpt_staffer' );
// adds meta box to member post types
function staffer_staff_meta_box() {
- $post_types = array(
- 'staff',
- );
- foreach ($post_types as $post_type) {
- add_meta_box('staffer_details', __('Staff Member Details', 'staffer'), 'staffer_staff_role_box', $post_type, 'side', 'high', $post_types);
- }
- }
-add_action('add_meta_boxes', 'staffer_staff_meta_box', 0);
+ $post_types = array(
+ 'staff',
+ );
+ foreach ( $post_types as $post_type ) {
+ add_meta_box( 'staffer_details', __( 'Staff Member Details', 'staffer' ), 'staffer_staff_role_box', $post_type, 'side', 'high', $post_types );
+ }
+}
+
+add_action( 'add_meta_boxes', 'staffer_staff_meta_box', 0 );
// prints the staffer post type boxes
-function staffer_staff_role_box($post) {
+function staffer_staff_role_box( $post ) {
// Use nonce for verification
- wp_nonce_field(plugin_basename(__FILE__), 'cpt_noncename');
+ wp_nonce_field( plugin_basename( __FILE__ ), 'cpt_noncename' );
// Use get_post_meta to retrieve an existing value from the database and use the value for the form
- $value = get_post_meta($post->ID, 'staffer_staff_title', true);
+ $value = get_post_meta( $post->ID, 'staffer_staff_title', true );
echo 'Title ';
- echo ' ';
- $value = get_post_meta($post->ID, 'staffer_staff_fb', true);
+ echo ' ';
+ $value = get_post_meta( $post->ID, 'staffer_staff_fb', true );
echo 'Facebook ';
- echo ' ';
- $value = get_post_meta($post->ID, 'staffer_staff_gplus', true);
+ echo ' ';
+ $value = get_post_meta( $post->ID, 'staffer_staff_gplus', true );
echo 'Google+ ';
- echo ' ';
- $value = get_post_meta($post->ID, 'staffer_staff_twitter', true);
+ echo ' ';
+ $value = get_post_meta( $post->ID, 'staffer_staff_twitter', true );
echo 'Twitter ';
- echo ' ';
- $value = get_post_meta($post->ID, 'staffer_staff_linkedin', true);
+ echo ' ';
+ $value = get_post_meta( $post->ID, 'staffer_staff_linkedin', true );
echo 'LinkedIn ';
- echo ' ';
- $value = get_post_meta($post->ID, 'staffer_staff_website', true);
+ echo ' ';
+ $value = get_post_meta( $post->ID, 'staffer_staff_website', true );
echo 'Website ';
- echo ' ';
- $value = get_post_meta($post->ID, 'staffer_staff_email', true);
+ echo ' ';
+ $value = get_post_meta( $post->ID, 'staffer_staff_email', true );
echo 'Email ';
- echo ' ';
- $value = get_post_meta($post->ID, 'staffer_staff_phone', true);
+ echo ' ';
+ $value = get_post_meta( $post->ID, 'staffer_staff_phone', true );
echo 'Phone Number ';
- echo ' ';
- }
+ echo ' ';
+
+ $staffer_synced_wp_profile = get_post_meta( $post->ID, 'staffer_synced_wp_profile', true );
+ $staffer_staff_email = get_post_meta( $post->ID, 'staffer_staff_email', true );
+ $guessed_wp_profile = false;
+ if ( ! empty( $staffer_staff_email ) ) {
+ $guessed_wp_profile = get_user_by( 'email', $staffer_staff_email );
+ }
+
+ if ( ! empty( $staffer_synced_wp_profile ) ) {
+ $args = array(
+ 'show_option_none' => 'Select an User',
+ 'orderby' => 'display_name',
+ 'order' => 'ASC',
+ 'multi' => false,
+ 'show' => 'display_name',
+ 'echo' => false,
+ 'selected' => $staffer_synced_wp_profile,
+ 'include_selected' => false,
+ 'name' => 'staffer_synced_wp_profile',
+ 'who' => 'authors'
+ );
+ } else if ( ! empty( $guessed_wp_profile->ID ) ) {
+ $args = array(
+ 'show_option_none' => 'Select an User',
+ 'orderby' => 'display_name',
+ 'order' => 'ASC',
+ 'multi' => false,
+ 'show' => 'display_name',
+ 'echo' => false,
+ 'selected' => $guessed_wp_profile->ID,
+ 'include_selected' => false,
+ 'name' => 'staffer_synced_wp_profile',
+ 'who' => 'authors'
+ );
+ } else {
+ $args = array(
+ 'show_option_none' => 'Select an User',
+ 'orderby' => 'display_name',
+ 'order' => 'ASC',
+ 'multi' => false,
+ 'show' => 'display_name',
+ 'echo' => false,
+ 'name' => 'staffer_synced_wp_profile',
+ 'who' => 'authors'
+ );
+ }
+ echo 'WordPress User Profile to Sync With: ';
+ echo wp_dropdown_users( $args );
+ echo 'If you don\'t find the user, its most probable that the user doesn\'t exist. Create an user to sync with. ';
+}
+
// saves the staffer post type details
-function staffer_staff_save_postdata($post_id) {
- if (!current_user_can('edit_page', $post_id)) {
- return;
- }
- else {
- if (!current_user_can('edit_post', $post_id))
- return;
- }
- if (!isset($_POST['cpt_noncename']) || !wp_verify_nonce($_POST['cpt_noncename'], plugin_basename(__FILE__)))
- return;
+function staffer_staff_save_postdata( $post_id ) {
+ if ( ! current_user_can( 'edit_page', $post_id ) ) {
+ return;
+ } else {
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
+ return;
+ }
+ }
+ if ( ! isset( $_POST['cpt_noncename'] ) || ! wp_verify_nonce( $_POST['cpt_noncename'], plugin_basename( __FILE__ ) ) ) {
+ return;
+ }
+
// get ID and save data
- $post_ID = $_POST['post_ID'];
+ $post_ID = $_POST['post_ID'];
+
//sanitize user input
- $title = ($_POST['staffer_staff_title']);
- $fb = ($_POST['staffer_staff_fb']);
- $gplus = ($_POST['staffer_staff_gplus']);
- $twitter = ($_POST['staffer_staff_twitter']);
- $linkedin = ($_POST['staffer_staff_linkedin']);
- $website = ($_POST['staffer_staff_website']);
- $email = ($_POST['staffer_staff_email']);
- $phone = ($_POST['staffer_staff_phone']);
- update_post_meta($post_ID, 'staffer_staff_title', $title);
- update_post_meta($post_ID, 'staffer_staff_fb', $fb);
- update_post_meta($post_ID, 'staffer_staff_gplus', $gplus);
- update_post_meta($post_ID, 'staffer_staff_twitter', $twitter);
- update_post_meta($post_ID, 'staffer_staff_linkedin', $linkedin);
- update_post_meta($post_ID, 'staffer_staff_website', $website);
- update_post_meta($post_ID, 'staffer_staff_email', $email);
- update_post_meta($post_ID, 'staffer_staff_phone', $phone);
+ $title = ( $_POST['staffer_staff_title'] );
+ $fb = ( $_POST['staffer_staff_fb'] );
+ $gplus = ( $_POST['staffer_staff_gplus'] );
+ $twitter = ( $_POST['staffer_staff_twitter'] );
+ $linkedin = ( $_POST['staffer_staff_linkedin'] );
+ $website = ( $_POST['staffer_staff_website'] );
+ $email = ( $_POST['staffer_staff_email'] );
+ $phone = ( $_POST['staffer_staff_phone'] );
+ $synced_wp_profile = ( isset( $_POST['staffer_synced_wp_profile'] ) && $_POST['staffer_synced_wp_profile'] > 1 ) ? ( $_POST['staffer_synced_wp_profile'] ) : '';
+
+ update_post_meta( $post_ID, 'staffer_staff_title', $title );
+ update_post_meta( $post_ID, 'staffer_staff_fb', $fb );
+ update_post_meta( $post_ID, 'staffer_staff_gplus', $gplus );
+ update_post_meta( $post_ID, 'staffer_staff_twitter', $twitter );
+ update_post_meta( $post_ID, 'staffer_staff_linkedin', $linkedin );
+ update_post_meta( $post_ID, 'staffer_staff_website', $website );
+ update_post_meta( $post_ID, 'staffer_staff_email', $email );
+ update_post_meta( $post_ID, 'staffer_staff_phone', $phone );
+ update_post_meta( $post_ID, 'staffer_synced_wp_profile', $synced_wp_profile );
+
+ $synced = staffer_sync_profile( $post_id );
+}
+
+add_action( 'save_post_staff', 'staffer_staff_save_postdata' );
+
+/**
+ * @param int $post_id post id of the staffer member
+ */
+function staffer_sync_profile( $post_id ) {
+ if ( empty( $post_id ) ) {
+ return;
+ }
+
+ // If this is just a revision, don't sync now.
+ if ( wp_is_post_revision( $post_id ) ) {
+ return;
+ }
+
+ $staffer_options = get_option( 'staffer' );
+ $wp_profile_sync_enabled = $staffer_options['wp_profile_sync'];
+ $synced_wp_profile = isset( $_POST['staffer_synced_wp_profile'] ) ? ( $_POST['staffer_synced_wp_profile'] ) : 0;
+
+ if ( ! empty( $wp_profile_sync_enabled ) && ( $synced_wp_profile > 0 ) ) {
+ $post = get_post( $post_id );
+
+ // Get the First Name & Last Name from the Team Member's Post Title
+ $first_name = '';
+ $last_name = '';
+ $full_name = $post->post_title;
+ if ( ! empty( $full_name ) ) {
+ $parts = explode( ' ', trim( $full_name ) );
+ if ( count( $parts ) > 1 ) {
+ $last_name = trim( array_pop( $parts ) );
+ $first_name = trim( implode( ' ', $parts ) );
+ } else {
+ $first_name = trim( implode( ' ', $parts ) );
+ }
+ }
+
+ $website = ( $_POST['staffer_staff_website'] );
+
+ $user_data = array(
+ 'ID' => $synced_wp_profile,
+ 'user_url' => $website,
+ 'first_name' => $first_name,
+ 'last_name' => $last_name,
+ );
+ $user_updated = wp_update_user( $user_data );
+
+ update_user_meta( $synced_wp_profile, 'synced_staffer_id', $post_id );
+
+ // Sync the extra social links.
+ if ( function_exists( 'axl_update_contactmethods' ) ) {
+ $facebook = ( $_POST['staffer_staff_fb'] );
+ $gplus = ( $_POST['staffer_staff_gplus'] );
+ $linkedin = ( $_POST['staffer_staff_linkedin'] );
+ $twitter = ( $_POST['staffer_staff_twitter'] );
+ $matched = preg_match( "|https?://(www\.)?twitter\.com/(#!/)?@?([^/]*)|", $twitter, $matches );
+ if ( $matched ) {
+ $twitter = $matches[3];
+ }
+
+ update_user_meta( $synced_wp_profile, 'googleplus', $gplus );
+ update_user_meta( $synced_wp_profile, 'twitter', $twitter );
+ update_user_meta( $synced_wp_profile, 'facebook', $facebook );
+ update_user_meta( $synced_wp_profile, 'linkedin', $linkedin );
+ }
+ } else if ( $synced_wp_profile > 0 ) {
+ // Simply store the post_id in synced user's meta to override author link.
+ update_user_meta( $synced_wp_profile, 'synced_staffer_id', $post_id );
+ }
+}
+
+/**
+ * Override the default posts url and replace with staffer member link.
+ *
+ * @param string $link author's posts url
+ * @param int $author_id author's id
+ * @param string $author_nicename author nicename
+ *
+ * @return string $link staffer member link
+ */
+function staffer_override_author_posts_url( $link, $author_id, $author_nicename = '' ) {
+ $staffer_options = get_option( 'staffer' );
+ $override_author_link = $staffer_options['override_author_link'];
+
+ if ( ! empty( $override_author_link ) ) {
+ $synced_staffer_id = get_user_meta( $author_id, 'synced_staffer_id', true );
+ if ( ! empty( $synced_staffer_id ) ) {
+ $link = user_trailingslashit( get_permalink( $synced_staffer_id ) );
+ }
+ }
+
+ return $link;
}
-add_action('save_post_staff', 'staffer_staff_save_postdata');
+
+add_filter( 'author_link', 'staffer_override_author_posts_url', 50, 3 );
// sets template override for custom template use
function staffer_staff_templates( $template ) {
$post_types = array( 'staff' );
- $staff_tax = 'department';
+ $staff_tax = 'department';
if ( is_post_type_archive( $post_types ) && ! file_exists( get_stylesheet_directory() . '/archive-staff.php' ) ) {
- $template = plugin_dir_path (__FILE__) . 'archive-staff.php';
+ $template = plugin_dir_path( __FILE__ ) . 'archive-staff.php';
}
if ( is_singular( $post_types ) && ! file_exists( get_stylesheet_directory() . '/single-staff.php' ) ) {
- $template = plugin_dir_path (__FILE__) . 'single-staff.php';
+ $template = plugin_dir_path( __FILE__ ) . 'single-staff.php';
}
- $staffer_options = get_option ('staffer');
+ $staffer_options = get_option( 'staffer' );
- if ( !isset ( $staffer_options['manual_mode'] ) ) {
+ if ( ! isset ( $staffer_options['manual_mode'] ) ) {
if ( is_tax( $staff_tax ) && ! file_exists( get_stylesheet_directory() . '/taxonomy-staffer-department.php' ) ) {
- $template = plugin_dir_path (__FILE__) . 'taxonomy-staffer-department.php';
+ $template = plugin_dir_path( __FILE__ ) . 'taxonomy-staffer-department.php';
}
}
+
return $template;
}
+
add_filter( 'template_include', 'staffer_staff_templates' );
// loads the default css
function staffer_load_css() {
- wp_register_style ('staffer-style', plugins_url( 'styles/staffer-styles.css', __FILE__) );
- wp_register_style ('staffer-font-awesome', plugins_url( 'styles/font-awesome.min.css', __FILE__) );
- $stafferoptions = get_option('staffer');
- if ($stafferoptions['disablecss'] != '1') {
- wp_enqueue_style ('staffer-style');
- }
- wp_enqueue_style ('staffer-font-awesome');
+ wp_register_style( 'staffer-style', plugins_url( 'styles/staffer-styles.css', __FILE__ ) );
+ wp_register_style( 'staffer-font-awesome', plugins_url( 'styles/font-awesome.min.css', __FILE__ ) );
+ $stafferoptions = get_option( 'staffer' );
+ if ( $stafferoptions['disablecss'] != '1' ) {
+ wp_enqueue_style( 'staffer-style' );
}
-add_action ('wp_enqueue_scripts','staffer_load_css');
+ wp_enqueue_style( 'staffer-font-awesome' );
+}
+
+add_action( 'wp_enqueue_scripts', 'staffer_load_css' );
// loads up any custom css
function staffer_custom_styles() {
- $stafferoptions = get_option ('staffer');
- if ($stafferoptions['customcss'] != '' ) {
- $staffercustomcss = $stafferoptions['customcss'];
- print ( '');
- }
- }
-add_action ('wp_head', 'staffer_custom_styles' );
+ $stafferoptions = get_option( 'staffer' );
+ if ( $stafferoptions['customcss'] != '' ) {
+ $staffercustomcss = $stafferoptions['customcss'];
+ print ( '' );
+ }
+}
+
+add_action( 'wp_head', 'staffer_custom_styles' );
// flush rewrite rules on activation and deactivation
function staffer_activate() {
@@ -390,147 +635,157 @@ function staffer_activate() {
// flush rewrite rules to prevent 404s
flush_rewrite_rules();
}
+
register_activation_hook( __FILE__, 'staffer_activate' );
function staffer_deactivate() {
flush_rewrite_rules();
}
+
register_deactivation_hook( __FILE__, 'staffer_deactivate' );
//enables thumbnail support if the theme does not
function staffer_thumbnail_check() {
- if ( ! current_theme_supports ('post-thumbnails') ) {
- add_theme_support ('post-thumbnails' );
- }
- }
-add_action ('after_setup_theme', 'staffer_thumbnail_check' );
-
+ if ( ! current_theme_supports( 'post-thumbnails' ) ) {
+ add_theme_support( 'post-thumbnails' );
+ }
+}
+
+add_action( 'after_setup_theme', 'staffer_thumbnail_check' );
+
// adds link to main staff archive
// too many people confused about accessing the page
function staffer_admin_menu() {
- $stafferoptions = get_option ('staffer');
+ $stafferoptions = get_option( 'staffer' );
if ( ! isset( $stafferoptions['manual_mode'] ) ) {
global $submenu;
- $url = home_url('/');
- $stafferoptions = get_option('staffer');
+ $url = home_url( '/' );
+ $stafferoptions = get_option( 'staffer' );
if ( $stafferoptions['slug'] == '' ) {
$slug = 'staff';
} else {
$slug = $stafferoptions['slug'];
}
- if ( get_option ('permalink_structure') ) {
- $url = $url . $slug;
+ if ( get_option( 'permalink_structure' ) ) {
+ $url = $url . $slug;
} else {
$url = $url . '?post_type=staff';
}
- $submenu['edit.php?post_type=staff'][] = array(__('View Staff Page', 'staffer'), 'manage_options', $url);
+ $submenu['edit.php?post_type=staff'][] = array( __( 'View Staff Page', 'staffer' ), 'manage_options', $url );
} else {
// nah
}
}
-add_action('admin_menu', 'staffer_admin_menu');
-// pre get posts allows modification of posts per page without affecting non-staffer pages
-function staffer_per_page_mod($query) {
- $stafferoptions = get_option ('staffer');
- $perpage = $stafferoptions['perpage'];
- $post_type = 'staff';
- $taxonomy = 'department';
- if ( $query->is_main_query() && !is_admin() && is_post_type_archive( $post_type ) ) {
- $query->set( 'posts_per_page', $perpage );
- } elseif ( $query->is_main_query() && !is_admin() && is_tax ($taxonomy) ) {
- $query->set( 'posts_per_page', $perpage );
- }
+add_action( 'admin_menu', 'staffer_admin_menu' );
+// pre get posts allows modification of posts per page without affecting non-staffer pages
+function staffer_per_page_mod( $query ) {
+ $stafferoptions = get_option( 'staffer' );
+ $perpage = $stafferoptions['perpage'];
+ $post_type = 'staff';
+ $taxonomy = 'department';
+ if ( $query->is_main_query() && ! is_admin() && is_post_type_archive( $post_type ) ) {
+ $query->set( 'posts_per_page', $perpage );
+ } elseif ( $query->is_main_query() && ! is_admin() && is_tax( $taxonomy ) ) {
+ $query->set( 'posts_per_page', $perpage );
}
-$stafferoptions = get_option ('staffer');
-$perpage = $stafferoptions['perpage'];
+}
+
+$stafferoptions = get_option( 'staffer' );
+$perpage = $stafferoptions['perpage'];
// if per page option is set, hooks into pre get posts
-if ($perpage != '' ) {
- add_action ('pre_get_posts', 'staffer_per_page_mod' );
+if ( $perpage != '' ) {
+ add_action( 'pre_get_posts', 'staffer_per_page_mod' );
}
// adds staff shortcode
-if( !function_exists( 'staffer_shortcode' ) ) {
- function staffer_shortcode( $atts ) {
- ob_start();
- extract( shortcode_atts( array (
- 'order' => 'DESC',
- 'orderby' => 'date',
- 'number' => -1,
- 'department' => '',
- ), $atts ) );
-
- if ( $department != '' ) {
- $tax_query = array (
- array (
- 'taxonomy' => 'department',
- 'field' => 'slug',
- 'terms' => $department,
- ),
- );
- } else {
- $tax_query = null;
- }
- $args = array(
- 'post_type' => 'staff',
- 'order' => $order,
- 'orderby' => $orderby,
- 'posts_per_page' => $number,
- 'tax_query' => $tax_query,
+function staffer_shortcode( $atts ) {
+ ob_start();
+
+ $attrib_values = shortcode_atts( array(
+ 'order' => 'DESC',
+ 'orderby' => 'date',
+ 'number' => - 1,
+ 'department' => '',
+ ), $atts );
+
+ $order = $attrib_values['order'];
+ $orderby = $attrib_values['orderby'];
+ $number = $attrib_values['number'];
+ $department = $attrib_values['department'];
+
+ if ( $department != '' ) {
+ $tax_query = array(
+ array(
+ 'taxonomy' => 'department',
+ 'field' => 'slug',
+ 'terms' => $department,
+ ),
);
- $staff_query = new WP_Query( $args );
- if ( $staff_query->have_posts() ) {
- global $post;
- $stafferoptions = get_option ( 'staffer' );
+ } else {
+ $tax_query = null;
+ }
+ $args = array(
+ 'post_type' => 'staff',
+ 'order' => $order,
+ 'orderby' => $orderby,
+ 'posts_per_page' => $number,
+ 'tax_query' => $tax_query,
+ );
+ $staff_query = new WP_Query( $args );
+ if ( $staff_query->have_posts() ) {
+ global $post;
+ $stafferoptions = get_option( 'staffer' );
- if (isset ($stafferoptions['gridlayout']) ) { ?>
+ if ( isset ( $stafferoptions['gridlayout'] ) ) { ?>