Issues with PHP classes and WordPress - php

I am currently trying to add new options to the Rename wp-login.php because it is barely being updated. The owner also allowed me to add new options to it.
The plugin functionality allows you to 'rename' /wp-admin/ and wp-login.php to a different location. I barely have any knowledge about PHP classes and, you guessed it, the whole plugin is basically created using PHP classes.
What I am trying to do:
When the field is empty, revert everything to /wp-admin/. Basically a disable option; I've got that, but when the field is left blank and you'll save it, it saves the value which was entered before. That's a problem; It should be empty when you save it blank.
Currently the field is in the "Permalinks" section of the settings menu, but I want to put the option in a custom page.
Also, how does this plugin saves the value of the field? I can't find anything, not even a register_setting function.
When I say 'the field', I'm talking about this field: <input id="rwl-page-input" type="text" name="rwl_page" value="' . $this->new_login_slug() . '">
Code is as follows:
<?php
if ( defined( 'ABSPATH' ) && ! class_exists( 'Rename_WP_Login' ) ) {
class Rename_WP_Login {
private $wp_login_php;
private function basename() {
return plugin_basename( __FILE__ );
}
private function path() {
return trailingslashit( dirname( __FILE__ ) );
}
private function use_trailing_slashes() {
return '/' === substr( get_option( 'permalink_structure' ), -1, 1 );
}
private function user_trailingslashit( $string ) {
return $this->use_trailing_slashes() ? trailingslashit( $string ) : untrailingslashit( $string );
}
private function wp_template_loader() {
global $pagenow;
$pagenow = 'index.php';
if ( ! defined( 'WP_USE_THEMES' ) ) {
define( 'WP_USE_THEMES', true );
}
wp();
if ( $_SERVER['REQUEST_URI'] === $this->user_trailingslashit( str_repeat( '-/', 10 ) ) ) {
$_SERVER['REQUEST_URI'] = $this->user_trailingslashit( '/wp-login-php/' );
}
require_once ABSPATH . WPINC . '/template-loader.php';
die;
}
private function new_login_slug() {
if (
( $slug = get_option( 'rwl_page' ) ) || (
is_multisite() &&
is_plugin_active_for_network( $this->basename() ) &&
( $slug = get_site_option( 'rwl_page', 'login' ) )
) ||
( $slug = 'login' )
) {
return $slug;
}
}
public function new_login_url( $scheme = null ) {
if ( get_option( 'permalink_structure' ) ) {
return $this->user_trailingslashit( home_url( '/', $scheme ) . $this->new_login_slug() );
} else {
return home_url( '/', $scheme ) . '?' . $this->new_login_slug();
}
}
public function __construct() {
register_activation_hook( $this->basename(), array( $this, 'activate' ) );
register_uninstall_hook( $this->basename(), array( 'Rename_WP_Login', 'uninstall' ) );
add_action( 'admin_init', array( $this, 'admin_init' ) );
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
add_action( 'network_admin_notices', array( $this, 'admin_notices' ) );
if ( is_multisite() && ! function_exists( 'is_plugin_active_for_network' ) ) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
}
add_filter( 'plugin_action_links_' . $this->basename(), array( $this, 'plugin_action_links' ) );
if ( is_multisite() && is_plugin_active_for_network( $this->basename() ) ) {
add_filter( 'network_admin_plugin_action_links_' . $this->basename(), array( $this, 'plugin_action_links' ) );
add_action( 'wpmu_options', array( $this, 'wpmu_options' ) );
add_action( 'update_wpmu_options', array( $this, 'update_wpmu_options' ) );
}
add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ), 1 );
add_action( 'wp_loaded', array( $this, 'wp_loaded' ) );
add_filter( 'site_url', array( $this, 'site_url' ), 10, 4 );
add_filter( 'network_site_url', array( $this, 'network_site_url' ), 10, 3 );
add_filter( 'wp_redirect', array( $this, 'wp_redirect' ), 10, 2 );
add_filter( 'site_option_welcome_email', array( $this, 'welcome_email' ) );
remove_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );
}
public function activate() {
add_option( 'rwl_redirect', '1' );
}
public static function uninstall() {
global $wpdb;
if ( is_multisite() ) {
$blogs = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" );
if ( $blogs ) {
foreach ( $blogs as $blog ) {
switch_to_blog( $blog );
delete_option( 'rwl_page' );
}
restore_current_blog();
}
delete_site_option( 'rwl_page' );
} else {
delete_option( 'rwl_page' );
}
}
public function wpmu_options() {
echo (
'<h3>' .
_x( 'Rename wp-login.php', 'Text string for settings page', 'rename-wp-login' ) .
'</h3>' .
'<p>' .
__( 'This option allows you to set a networkwide default, which can be overridden by individual sites. Simply go to to the site’s permalink settings to change the url.', 'rename-wp-login' ) .
'</p>' .
'<table class="form-table">' .
'<tr valign="top">' .
'<th scope="row">' .
__( 'Networkwide default', 'rename-wp-login' ) .
'</th>' .
'<td>' .
'<input id="rwl-page-input" type="text" name="rwl_page" value="' . get_site_option( 'rwl_page', 'login' ) . '">' .
'</td>' .
'</tr>' .
'</table>'
);
}
public function update_wpmu_options() {
if (
( $rwl_page = sanitize_title_with_dashes( $_POST['rwl_page'] ) ) &&
strpos( $rwl_page, 'wp-login' ) === false &&
! in_array( $rwl_page, $this->forbidden_slugs() )
) {
update_site_option( 'rwl_page', $rwl_page );
}
}
public function admin_init() {
global $pagenow;
add_settings_section(
'rename-wp-login-section',
_x( 'Rename wp-login.php', 'Text string for settings page', 'rename-wp-login' ),
array( $this, 'rwl_section_desc' ),
'permalink'
);
add_settings_field(
'rwl-page',
'<label for="rwl-page">' . __( 'Login url', 'rename-wp-login' ) . '</label>',
array( $this, 'rwl_page_input' ),
'permalink',
'rename-wp-login-section'
);
if ( isset( $_POST['rwl_page'] ) && $pagenow === 'options-permalink.php' ) {
if (
( $rwl_page = sanitize_title_with_dashes( $_POST['rwl_page'] ) ) &&
strpos( $rwl_page, 'wp-login' ) === false &&
! in_array( $rwl_page, $this->forbidden_slugs() )
) {
if ( is_multisite() && $rwl_page === get_site_option( 'rwl_page', 'login' ) ) {
delete_option( 'rwl_page' );
} else {
update_option( 'rwl_page', $rwl_page );
}
}
}
if ( get_option( 'rwl_redirect' ) ) {
delete_option( 'rwl_redirect' );
if ( is_multisite() && is_super_admin() && is_plugin_active_for_network( $this->basename() ) ) {
$redirect = network_admin_url( 'settings.php#rwl-page-input' );
} else {
$redirect = admin_url( 'options-permalink.php#rwl-page-input' );
}
wp_safe_redirect( $redirect );
die;
}
}
public function rwl_section_desc() {
if ( is_multisite() && is_super_admin() && is_plugin_active_for_network( $this->basename() ) ) {
echo (
'<p>' .
sprintf(
__( 'To set a networkwide default, go to %s.', 'rename-wp-login' ),
'<a href="' . esc_url( network_admin_url( 'settings.php#rwl-page-input' ) ) . '">' .
__( 'Network Settings', 'rename-wp-login' ) .
'</a>'
) .
'</p>'
);
}
}
public function rwl_page_input() {
if ( get_option( 'permalink_structure' ) ) {
echo '<code>' . trailingslashit( home_url() ) . '</code> <input id="rwl-page-input" type="text" name="rwl_page" value="' . $this->new_login_slug() . '">' . ( $this->use_trailing_slashes() ? ' <code>/</code>' : '' );
} else {
echo '<code>' . trailingslashit( home_url() ) . '?</code> <input id="rwl-page-input" type="text" name="rwl_page" value="' . $this->new_login_slug() . '">';
}
}
public function admin_notices() {
global $pagenow;
if ( ! is_network_admin() && $pagenow === 'options-permalink.php' && isset( $_GET['settings-updated'] ) ) {
echo '<div class="notice notice-success is-dismissible"><p>' . sprintf( __( 'Your login page is now here: %s. Bookmark this page!', 'rename-wp-login' ), '<strong>' . $this->new_login_url() . '</strong>' ) . '</p></div>';
}
}
public function plugin_action_links( $links ) {
if ( is_network_admin() && is_plugin_active_for_network( $this->basename() ) ) {
array_unshift( $links,
'<a href="' . esc_url( network_admin_url( 'settings.php#rwl-page-input' ) ) . '">' .
__( 'Settings', 'rename-wp-login' ) .
'</a>'
);
} elseif ( ! is_network_admin() ) {
array_unshift( $links,
'<a href="' . esc_url( admin_url( 'options-permalink.php#rwl-page-input' ) ) . '">' .
__( 'Settings', 'rename-wp-login' ) .
'</a>'
);
}
return $links;
}
public function plugins_loaded() {
global $pagenow;
load_plugin_textdomain( 'rename-wp-login' );
if (
! is_multisite() && (
strpos( $_SERVER['REQUEST_URI'], 'wp-signup' ) !== false ||
strpos( $_SERVER['REQUEST_URI'], 'wp-activate' ) !== false
)
) {
wp_die( __( 'This feature is not enabled.', 'rename-wp-login' ), '', array( 'response' => 403 ) );
}
$request = parse_url( $_SERVER['REQUEST_URI'] );
if ( (
strpos( $_SERVER['REQUEST_URI'], 'wp-login.php' ) !== false ||
untrailingslashit( $request['path'] ) === site_url( 'wp-login', 'relative' )
) &&
! is_admin()
) {
$this->wp_login_php = true;
$_SERVER['REQUEST_URI'] = $this->user_trailingslashit( '/' . str_repeat( '-/', 10 ) );
$pagenow = 'index.php';
} elseif (
untrailingslashit( $request['path'] ) === home_url( $this->new_login_slug(), 'relative' ) || (
! get_option( 'permalink_structure' ) &&
isset( $_GET[$this->new_login_slug()] ) &&
empty( $_GET[$this->new_login_slug()] )
) ) {
$pagenow = 'wp-login.php';
}
}
public function wp_loaded() {
global $pagenow;
if ( is_admin() && ! is_user_logged_in() && ! defined( 'DOING_AJAX' ) ) {
wp_die( __( 'You must log in to access the admin area.', 'rename-wp-login' ), '', array( 'response' => 403 ) );
}
$request = parse_url( $_SERVER['REQUEST_URI'] );
if (
$pagenow === 'wp-login.php' &&
$request['path'] !== $this->user_trailingslashit( $request['path'] ) &&
get_option( 'permalink_structure' )
) {
wp_safe_redirect( $this->user_trailingslashit( $this->new_login_url() ) . ( ! empty( $_SERVER['QUERY_STRING'] ) ? '?' . $_SERVER['QUERY_STRING'] : '' ) );
die;
} elseif ( $this->wp_login_php ) {
if (
( $referer = wp_get_referer() ) &&
strpos( $referer, 'wp-activate.php' ) !== false &&
( $referer = parse_url( $referer ) ) &&
! empty( $referer['query'] )
) {
parse_str( $referer['query'], $referer );
if (
! empty( $referer['key'] ) &&
( $result = wpmu_activate_signup( $referer['key'] ) ) &&
is_wp_error( $result ) && (
$result->get_error_code() === 'already_active' ||
$result->get_error_code() === 'blog_taken'
) ) {
wp_safe_redirect( $this->new_login_url() . ( ! empty( $_SERVER['QUERY_STRING'] ) ? '?' . $_SERVER['QUERY_STRING'] : '' ) );
die;
}
}
$this->wp_template_loader();
} elseif ( $pagenow === 'wp-login.php' ) {
global $error, $interim_login, $action, $user_login;
#require_once ABSPATH . 'wp-login.php';
die;
}
}
public function site_url( $url, $path, $scheme, $blog_id ) {
return $this->filter_wp_login_php( $url, $scheme );
}
public function network_site_url( $url, $path, $scheme ) {
return $this->filter_wp_login_php( $url, $scheme );
}
public function wp_redirect( $location, $status ) {
return $this->filter_wp_login_php( $location );
}
public function filter_wp_login_php( $url, $scheme = null ) {
if ( strpos( $url, 'wp-login.php' ) !== false ) {
if ( is_ssl() ) {
$scheme = 'https';
}
$args = explode( '?', $url );
if ( isset( $args[1] ) ) {
parse_str( $args[1], $args );
$url = add_query_arg( $args, $this->new_login_url( $scheme ) );
} else {
$url = $this->new_login_url( $scheme );
}
}
return $url;
}
public function welcome_email( $value ) {
return str_replace( 'wp-login.php', trailingslashit( get_site_option( 'rwl_page', 'login' ) ), $value );
}
public function forbidden_slugs() {
$wp = new WP;
return array_merge( $wp->public_query_vars, $wp->private_query_vars );
}
}
new Rename_WP_Login;
}
I would really, really appreciate it if anyone can help me out with this!

The first
Also, how does this plugin saves the value of the field? I can't find anything, not even a register_setting function.
This plugin save the value by this function:
public function update_wpmu_options() {
if (
( $rwl_page = sanitize_title_with_dashes( $_POST['rwl_page'] ) ) &&
strpos( $rwl_page, 'wp-login' ) === false &&
! in_array( $rwl_page, $this->forbidden_slugs() )
) {
update_site_option( 'rwl_page', $rwl_page );
}
}
You can read more at: update_site_option
In admin_init function have
add_settings_field(
'rwl-page',
'<label for="rwl-page">' . __( 'Login url', 'rename-wp-login' ) . '</label>',
array( $this, 'rwl_page_input' ),
'permalink',
'rename-wp-login-section'
);
This function will get value saved. If you let the field blank this value won't be update. That's why you got old value of it.
If you want revert all to old version you can remove this plugin.
Hope it can help.
I'm just coder had try this plugin not dev it. xD

Related

How To Create extra download page on Wordpress

I am trying to create a separate download page in WordPress when the visitor clicks on a download button having link https://example.com/(any_post)/download, it will open a download page having the destination url.
What i have done?
I have created a custom field that takes link from post for this I uses below:
// Meta Box Class: DownloadLinkMetaBox
// Get the field value: $metavalue = get_post_meta( $post_id, $field_id, true );
class DownloadLinkMetaBox{
private $screen = array(
'post',
);
private $meta_fields = array(
array(
'label' => 'Download Link',
'id' => 'download_id',
'type' => 'text',
)
);
public function __construct() {
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
add_action( 'save_post', array( $this, 'save_fields' ) );
}
public function add_meta_boxes() {
foreach ( $this->screen as $single_screen ) {
add_meta_box(
'DownloadLink',
__( 'DownloadLink', '' ),
array( $this, 'meta_box_callback' ),
$single_screen,
'normal',
'default'
);
}
}
public function meta_box_callback( $post ) {
wp_nonce_field( 'DownloadLink_data', 'DownloadLink_nonce' );
$this->field_generator( $post );
}
public function field_generator( $post ) {
$output = '';
foreach ( $this->meta_fields as $meta_field ) {
$label = '<label for="' . $meta_field['id'] . '">' . $meta_field['label'] . '</label>';
$meta_value = get_post_meta( $post->ID, $meta_field['id'], true );
if ( empty( $meta_value ) ) {
if ( isset( $meta_field['default'] ) ) {
$meta_value = $meta_field['default'];
}
}
switch ( $meta_field['type'] ) {
default:
$input = sprintf(
'<input %s id="%s" name="%s" type="%s" value="%s">',
$meta_field['type'] !== 'color' ? 'style="width: 100%"' : '',
$meta_field['id'],
$meta_field['id'],
$meta_field['type'],
$meta_value
);
}
$output .= $this->format_rows( $label, $input );
}
echo '<table class="form-table"><tbody>' . $output . '</tbody></table>';
}
public function format_rows( $label, $input ) {
return '<tr><th>'.$label.'</th><td>'.$input.'</td></tr>';
}
public function save_fields( $post_id ) {
if ( ! isset( $_POST['DownloadLink_nonce'] ) )
return $post_id;
$nonce = $_POST['DownloadLink_nonce'];
if ( !wp_verify_nonce( $nonce, 'DownloadLink_data' ) )
return $post_id;
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return $post_id;
foreach ( $this->meta_fields as $meta_field ) {
if ( isset( $_POST[ $meta_field['id'] ] ) ) {
switch ( $meta_field['type'] ) {
case 'email':
$_POST[ $meta_field['id'] ] = sanitize_email( $_POST[ $meta_field['id'] ] );
break;
case 'text':
$_POST[ $meta_field['id'] ] = sanitize_text_field( $_POST[ $meta_field['id'] ] );
break;
}
update_post_meta( $post_id, $meta_field['id'], $_POST[ $meta_field['id'] ] );
} else if ( $meta_field['type'] === 'checkbox' ) {
update_post_meta( $post_id, $meta_field['id'], '0' );
}
}
}
}
if (class_exists('DownloadLinkMetabox')) {
new DownloadLinkMetabox;
};
That takes link perfectly and also able to show on front but not able to create another page.
Below code used to show in frontend
add_action( 'generate_after_entry_header', 'wpsh_single_posts_custom_meta_fields', 9 );
function wpsh_single_posts_custom_meta_fields(){
$post_id = get_the_ID();
$post = get_post( $post_id );
$download_id = get_post_meta( $post->ID, 'download_id' );
if( $download_id ) { ?>
<div class="wp-block-buttons aligncenter">
<div class="wp-block-button">
<a style='text-transform: uppercase;' href="<?php the_permalink();?>download/" class="wp-block-button__link has-vivid-cyan-blue-background-color download ripple">
<i class="material-icons">
<svg class="icon" fill="currentColor" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path d="M0 0h24v24H0z" fill="none" />
<path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM17 13l-5 5-5-5h3V9h4v4h3z" />
</svg>
</i> Download</a>
</div>
</div>
<?php }
}
Above code will show button if the download id have link and the button have link example.com/any_post/download. Now here i don't know how to serve the link that the download_id holds of the post from it visits to .../download
I'm thinking to create a template page that serve the link but not able to do
in your functions:
Once you have added all your code make sure to flush your rewrite rules by going to: Settings > Permalinks and clicking 'save changes'
Set your rewrite rules:
function custom_add_rewrite_rule(){
$posts = get_posts( array( 'numberposts' => -1, 'post_type' => 'post') );
if( $posts ){
foreach($posts as $post ){
add_rewrite_rule(
$post->post_name . '/download/?$',
'index.php?name=' . $post->post_name . '&post_action=download&post_id=' . $post->ID,
'top'
);
}
}
}
add_action('init', 'custom_add_rewrite_rule');
add your query_vars:
function add_query_vars_filter( $vars ){
$vars[] = "post_action";
$vars[] = "post_id";
return $vars;
}
add_filter( 'query_vars', 'add_query_vars_filter' );
then include your custom template:
function include_custom_template($template){
if( get_query_var('post_action') && get_query_var('post_action') == 'download'){
$template = get_template_directory() ."/download.php";
}
return $template;
}
add_filter('template_include', 'include_custom_template');
and finally make a file called download.php in your theme root and call your parameters
$download_id = get_post_meta( get_query_var('post_id'), 'download_id' );
//Your Code

Metabox with multi checkbox in WooCommerce admin single orders

I added successfully a Metabox with a multi checkbox field that is displayed on admin single order pages and works perfectly.
I am using Multi checkbox fields in Woocommerce backend answer code for that multi checkbox.
// Adding Meta container admin shop_order pages
add_action( 'add_meta_boxes', 'em_add_meta_boxes' );
if ( ! function_exists( 'em_add_meta_boxes' ) )
{
function em_add_meta_boxes()
{
add_meta_box( 'em_other_fields', __('Employee Extra Actions','woocommerce'), 'em_add_other_fields_for_order_empl', 'shop_order', 'side', 'core' );
}
}
// Adding Meta field in the meta container admin shop_order pages
if ( ! function_exists( 'em_add_other_fields_for_order_empl' ) )
{
function em_add_other_fields_for_order_empl()
{
global $post;
echo '<div class="options_group">';
woocommerce_wp_multi_checkbox( array(
'id' => 'employee_actions12',
'name' => 'employee_actions12[]',
'label' => __('Levels', 'woocommerce'),
'options' => array(
'tee' => __( 'MBO', 'woocommerce' ),
'saa' => __( 'HBO', 'woocommerce' ),
'tee1' => __( 'WO', 'woocommerce' ),
)
) );
echo '</div>';
}
}
Final part of code is to save at database, Here is it:
add_action( 'save_post', 'save_product_options_custom_fields32', 30, 1 );
function save_product_options_custom_fields32( $post_id ){
if( isset( $_POST['employee_actions12'] ) ){
$post_data = $_POST['employee_actions12'];
// Multi data sanitization
$sanitize_data = array();
if( is_array($post_data) && sizeof($post_data) > 0 ){
foreach( $post_data as $value ){
$sanitize_data[] = esc_attr( $value );
}
}
update_post_meta( $post_id, 'employee_actions12', $sanitize_data );
}
}
I know code works for product pages with action: 'woocommerce_product_process_meta'
So, i need help for saving at db, an fixing error notice for array (i think this can happen if we select default value).
There was another issue with the function woocommerce_wp_multi_checkbox() that I have updated again (when used in a custom metabox).
I have also revisited all your code, specially the last function that saves the multi-checkboxes selected values.
The complete code:
// WooCommerce admin custom multi checkbox field function
function woocommerce_wp_multi_checkbox( $field ) {
global $thepostid, $post;
if( ! $thepostid ) {
$thepostid = $post->ID;
}
$field['value'] = get_post_meta( $thepostid, $field['id'], true );
$thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
$field['class'] = isset( $field['class'] ) ? $field['class'] : 'select short';
$field['style'] = isset( $field['style'] ) ? $field['style'] : '';
$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
$field['value'] = isset( $field['value'] ) ? $field['value'] : array();
$field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id'];
$field['desc_tip'] = isset( $field['desc_tip'] ) ? $field['desc_tip'] : false;
echo '<fieldset class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '">
<legend>' . wp_kses_post( $field['label'] ) . '</legend>';
if ( ! empty( $field['description'] ) && false !== $field['desc_tip'] ) {
echo wc_help_tip( $field['description'] );
}
echo '<ul class="wc-radios">';
foreach ( $field['options'] as $key => $value ) {
echo '<li><label><input
name="' . esc_attr( $field['name'] ) . '"
value="' . esc_attr( $key ) . '"
type="checkbox"
class="' . esc_attr( $field['class'] ) . '"
style="' . esc_attr( $field['style'] ) . '"
' . ( is_array( $field['value'] ) && in_array( $key, $field['value'] ) ? 'checked="checked"' : '' ) . ' /> ' . esc_html( $value ) . '</label>
</li>';
}
echo '</ul>';
if ( ! empty( $field['description'] ) && false === $field['desc_tip'] ) {
echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
}
echo '</fieldset>';
}
// Adding a custom Metabox on WooCommerce single orders
add_action( 'add_meta_boxes', 'add_custom_shop_order_metabox' );
function add_custom_shop_order_metabox(){
add_meta_box(
'custom_shop_order_metabox',
__('Employee Extra Actions', 'woocommerce'),
'content_custom_shop_order_metabox',
'shop_order',
'side',
'core'
);
}
// Custom Metabox content on WooCommerce single orders
function content_custom_shop_order_metabox() {
global $thepostid, $post;
echo '<div class="options_group">';
woocommerce_wp_multi_checkbox( array(
'id' => 'employee_actions12',
'name' => 'employee_actions12[]',
'label' => __('Levels', 'woocommerce'),
'options' => array(
'tee' => __( 'MBO', 'woocommerce' ),
'saa' => __( 'HBO', 'woocommerce' ),
'tee1' => __( 'WO', 'woocommerce' ),
),
) );
echo '</div>';
}
// Save WooCommerce single orders Custom Metabox field values
add_action( 'save_post_shop_order', 'save_custom_shop_order_metabox_field_values' );
function save_custom_shop_order_metabox_field_values( $post_id ){
if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
|| ! current_user_can( 'edit_shop_order', $post_id ) ) {
return;
}
if( isset( $_POST['employee_actions12'] ) ){
update_post_meta( $post_id, 'employee_actions12', wc_clean($_POST['employee_actions12']) );
}
}
Code goes in functions.php file of the active child theme (or active theme). Tested and works.

WP_List_Table Not showing any entries

Missing WP_List_Table Entries Screenshot Here
I'm trying to populate a list table in WordPress using WP_List_Table with country and state codes from WooCommerce, but it seems that either :display(), :prepare-items() or :column_default is failing me. Been staring myself blind for hours and I can't track down what's happening.
The class setup looks as follows:
<?php
if ( ! class_exists( 'WP_List_Table' ) ) {
require_once ABSPATH . 'wp-admin/includes/screen.php';
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
}
class My_List_Table extends WP_List_Table {
public function __construct() {
parent::__construct(
array(
'singular' => __( 'state', 'my-text-domain' ),
'plural' => __( 'states', 'my-text-domain' ),
'ajax' => false,
)
);
}
public function get_columns() {
$columns = array(
'cb' => '<input type="checkbox" />',
'col_state_name' => __( 'Region Name', 'my-text-domain' ),
'col_state_id' => __( 'Region Code', 'my-text-domain' ),
);
return $columns;
}
public function column_default( $item, $column_name ) {
switch ( $column_name ) {
case 'col_state_id':
case 'col_state_name':
return $item[ $column_name ];
default:
return $item;
}
}
public function my_load_states() {
if ( get_option( 'my_countries' ) && get_option( 'my_current_country' ) && get_option( 'my_states_' . get_option( 'my_current_country' ) ) ) {
$states = get_option( 'my_states_' . get_option( 'my_current_country' ) );
update_option( 'myplugin', true );
return $states;
} else {
$states = WC()->countries->get_states( get_option( 'my_current_country' ) );
if ( is_array( $states ) ) {
return $states;
} else {
update_option( 'myplugin', true );
return '';
}
}
}
public function get_states() {
$data = array();
if ( get_option( 'my_states_' . get_option( 'my_current_country' ) ) && ! empty( get_option( 'my_states_' . get_option( 'my_current_country' ) ) ) && get_option( 'my_country' ) && in_array( get_option( 'my_current_country' ), get_option( 'my_countries' ), true ) ) {
$states = get_option( 'my_states_' . get_option( 'my_current_country' ) );
update_option( 'myplugin', true );
} else {
$states = $this->my_load_states();
}
if ( ! empty( $states ) ) {
foreach ( $states as $code => $name ) {
$temp = array(
'col_state_name' => $name,
'col_state_id' => $code,
);
array_push( $data, $temp );
}
return $data;
} else {
return '';
}
}
public function prepare_items() {
$this->_column_headers = $this->get_column_info();
$this->process_bulk_action();
$data = $this->get_states();
if ( ! empty( $data ) && is_array( $data ) ) {
usort( $data, array( &$this, 'usort_reorder' ) );
$per_page = count( $data );
$total_items = count( $data );
}
$current_page = $this->get_pagenum();
if ( is_array( $data ) && count( $data ) > 1 ) {
$found_data = array_slice( $data, ( ( $current_page - 1 ) * $per_page ), $per_page );
} else {
$found_data = $data;
$total_items = 0;
}
$this->set_pagination_args(
array(
'total_items' => $total_items,
'per_page' => $per_page,
)
);
$this->items = $found_data;
}
public function no_items() {
esc_html_e( 'No states avaliable.', 'my-text-domain' );
}
}
I'm initiating things through this:
<?php
class My_Admin {
...
public function my_add_menu_item() {
add_submenu_page(
'woocommerce',
'Locations',
'Locations',
'manage_options',
'my_states',
array( $this, 'my_settings_page' ),
);
}
public function my_settings_page() {
$slp_obj = new My_List_Table();
$slp_obj->prepare_items();
$slp_obj->display();
}
}
?>

Override WordPress plugin class to change upload image size

I'm trying to change the function inside the handler class for uploading user image from front end using the the code which mostly works in situations like this one:
class Custom_Class extends Main_Class {
function __construct() {
remove_action('default_action', array($this));
add_action('new_action', array($this));
}
/* custom code from here on */
}
new Custom_Class
The goal is to change the $image->resize value to 320px, but I can not even remove the action, and the original code looks like this:
class UR_Form_Handler {
/**
* Hook in methods.
*/
public static function init() {
add_action( 'template_redirect', array( __CLASS__, 'redirect_reset_password_link' ) );
add_action( 'template_redirect', array( __CLASS__, 'save_profile_details' ) );
add_action( 'template_redirect', array( __CLASS__, 'save_change_password' ) );
add_action( 'wp_loaded', array( __CLASS__, 'process_login' ), 20 );
add_action( 'wp_loaded', array( __CLASS__, 'process_lost_password' ), 20 );
add_action( 'wp_loaded', array( __CLASS__, 'process_reset_password' ), 20 );
add_action( 'user_registration_before_customer_login_form', array( __CLASS__, 'export_confirmation_request' ) );
}
/**
* Save/update a profile fields if the form was submitted through the user account page.
*
* #return mixed
*/
public function save_profile_details() {
if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
return;
}
if ( empty( $_POST['action'] ) || 'save_profile_details' !== $_POST['action'] || empty( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'save_profile_details' ) ) {
return;
}
$user_id = get_current_user_id();
if ( $user_id <= 0 ) {
return;
}
if ( has_action( 'uraf_profile_picture_buttons' ) ) {
if ( isset( $_POST['profile_pic_url'] ) && ! empty( $_POST['profile_pic_url'] ) ) {
update_user_meta( $user_id, 'user_registration_profile_pic_url', $_POST['profile_pic_url'] );
}
} else {
if ( isset( $_FILES['profile-pic'] ) && $_FILES['profile-pic']['size'] ) {
if ( ! function_exists( 'wp_handle_upload' ) ) {
require_once ABSPATH . 'wp-admin/includes/file.php';
}
$upload = $_FILES['profile-pic'];
$upload_overrides = array(
'action' => 'save_profile_details',
);
$uploaded = wp_handle_upload( $upload, $upload_overrides );
if ( $uploaded && ! isset( $uploaded['error'] ) ) {
$image = wp_get_image_editor( $uploaded['file'] );
if ( ! is_wp_error( $image ) ) {
$image->resize( 150, 150, true );
$image->save( $uploaded['file'] );
}
update_user_meta( $user_id, 'user_registration_profile_pic_url', $uploaded['url'] );
} else {
ur_add_notice( $uploaded['error'], 'error' );
}
} elseif ( UPLOAD_ERR_NO_FILE !== $_FILES['profile-pic']['error'] ) {
switch ( $_FILES['profile-pic']['error'] ) {
case UPLOAD_ERR_INI_SIZE:
ur_add_notice( __( 'File size exceed, please check your file size.', 'user-registration' ), 'error' );
break;
default:
ur_add_notice( __( 'Something went wrong while uploading, please contact your site administrator.', 'user-registration' ), 'error' );
break;
}
} elseif ( empty( $_POST['profile-pic-url'] ) ) {
$upload_dir = wp_upload_dir();
$profile_url = get_user_meta( $user_id, 'user_registration_profile_pic_url', true );
// Check if profile already set?
if ( $profile_url ) {
// Then delete file and user meta.
$profile_url = $upload_dir['basedir'] . explode( '/uploads', $profile_url )[1];
if ( ! empty( $profile_url ) && file_exists( $profile_url ) ) {
#unlink( $profile_url );
}
delete_user_meta( $user_id, 'user_registration_profile_pic_url' );
}
}
}
$form_id_array = get_user_meta( $user_id, 'ur_form_id' );
$form_id = 0;
if ( isset( $form_id_array[0] ) ) {
$form_id = $form_id_array[0];
}
$profile = user_registration_form_data( $user_id, $form_id );
foreach ( $profile as $key => $field ) {
if ( ! isset( $field['type'] ) ) {
$field['type'] = 'text';
}
// Get Value.
switch ( $field['type'] ) {
case 'checkbox':
if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) {
$_POST[ $key ] = $_POST[ $key ];
} else {
$_POST[ $key ] = (int) isset( $_POST[ $key ] );
}
break;
default:
$_POST[ $key ] = isset( $_POST[ $key ] ) ? ur_clean( $_POST[ $key ] ) : '';
break;
}
// Hook to allow modification of value.
$_POST[ $key ] = apply_filters( 'user_registration_process_myaccount_field_' . $key, $_POST[ $key ] );
$disabled = false;
if ( isset( $field['custom_attributes'] ) && isset( $field['custom_attributes']['readonly'] ) && isset( $field['custom_attributes']['disabled'] ) ) {
if ( 'readonly' === $field['custom_attributes']['readonly'] || 'disabled' === $field['custom_attributes']['disabled'] ) {
$disabled = true;
}
}
if ( ! empty( $_POST[ $key ] ) ) {
// Validation rules.
if ( ! empty( $field['validate'] ) && is_array( $field['validate'] ) ) {
foreach ( $field['validate'] as $rule ) {
switch ( $rule ) {
case 'email':
$_POST[ $key ] = strtolower( $_POST[ $key ] );
if ( ! is_email( $_POST[ $key ] ) ) {
ur_add_notice( sprintf( __( '%s is not a valid email address.', 'user-registration' ), '<strong>' . $field['label'] . '</strong>' ), 'error' );
}
break;
}
}
}
}
}// End foreach().
do_action( 'user_registration_after_save_profile_validation', $user_id, $profile );
if ( 0 === ur_notice_count( 'error' ) ) {
$user_data = array();
foreach ( $profile as $key => $field ) {
$new_key = str_replace( 'user_registration_', '', $key );
if ( in_array( $new_key, ur_get_user_table_fields() ) ) {
if ( $new_key === 'display_name' ) {
$user_data['display_name'] = $_POST[ $key ];
} else {
$user_data[ $new_key ] = $_POST[ $key ];
}
} else {
$update_key = $key;
if ( in_array( $new_key, ur_get_registered_user_meta_fields() ) ) {
$update_key = str_replace( 'user_', '', $new_key );
}
$disabled = isset( $field['custom_attributes']['disabled'] ) ? $field['custom_attributes']['disabled'] : '';
if ( $disabled !== 'disabled' ) {
update_user_meta( $user_id, $update_key, $_POST[ $key ] );
}
}
}
if ( count( $user_data ) > 0 ) {
$user_data['ID'] = get_current_user_id();
wp_update_user( $user_data );
}
do_action( 'user_registration_save_profile_details', $user_id, $form_id );
wp_safe_redirect( ur_get_endpoint_url( 'edit-profile', '', ur_get_page_permalink( 'myaccount' ) ) );
exit;
}
}
}
Either I get Fatal error: Cannot make static method UR_Form_Handler::save_profile_details() non static in class Custom_UR_Form_Handler, or the override doesn't work at all, I'm not sure if I'm even doing this the right way, maybe there's no need to override the entire function, but I'm stuck with this, any help or idea would be much appreciated, thanks.

Wordpress 'Our Team' Plugin

I currently have the 'Our Team' plugin installed to display team members.
At the moment, the staff description (that appears in the WISYWIG editor area), is pulled through onto the team page along with all the other staff details.
As there is quite a bit of text for each, i would like to have it so that there is just a 'Read about me' link, and the description text appears in a lightbox instead.
I already have a Lightbox plugin in use on the website (WP Lightbox 2), but just need to know how i can change the 'Our Team' template file so that it displays the link rather than the whole block of text.
Below is the 'woothemes-our-team-template.php' file:
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! function_exists( 'woothemes_get_our_team' ) ) {
/**
* Wrapper function to get the team members from the Woothemes_Our_Team class.
* #param string/array $args Arguments.
* #since 1.0.0
* #return array/boolean Array if true, boolean if false.
*/
function woothemes_get_our_team ( $args = '' ) {
global $woothemes_our_team;
return $woothemes_our_team->get_our_team( $args );
} // End woothemes_get_our_team()
}
/**
* Enable the usage of do_action( 'woothemes_our_team' ) to display team members within a theme/plugin.
*
* #since 1.0.0
*/
add_action( 'woothemes_our_team', 'woothemes_our_team' );
if ( ! function_exists( 'woothemes_our_team' ) ) {
/**
* Display or return HTML-formatted team members.
* #param string/array $args Arguments.
* #since 1.0.0
* #return string
*/
function woothemes_our_team ( $args = '' ) {
global $post, $more;
$defaults = apply_filters( 'woothemes_our_team_default_args', array(
'limit' => 12,
'per_row' => null,
'orderby' => 'menu_order',
'order' => 'DESC',
'id' => 0,
'slug' => null,
'display_author' => true,
'display_additional' => true,
'display_avatar' => true,
'display_url' => true,
'display_twitter' => true,
'display_author_archive' => true,
'display_role' => true,
'contact_email' => true,
'tel' => true,
'effect' => 'fade', // Options: 'fade', 'none'
'pagination' => false,
'echo' => true,
'size' => 250,
'title' => '',
'before' => '<div class="widget widget_woothemes_our_team">',
'after' => '</div>',
'before_title' => '<h2>',
'after_title' => '</h2>',
'category' => 0
) );
$args = wp_parse_args( $args, $defaults );
// Allow child themes/plugins to filter here.
$args = apply_filters( 'woothemes_our_team_args', $args );
$html = '';
do_action( 'woothemes_our_team_before', $args );
// The Query.
$query = woothemes_get_our_team( $args );
// The Display.
if ( ! is_wp_error( $query ) && is_array( $query ) && count( $query ) > 0 ) {
$class = '';
if ( is_numeric( $args['per_row'] ) ) {
$class .= ' columns-' . intval( $args['per_row'] );
}
if ( 'none' != $args['effect'] ) {
$class .= ' effect-' . $args['effect'];
}
$html .= $args['before'] . "\n";
if ( '' != $args['title'] ) {
$html .= html_entity_decode( $args['before_title'] ) . esc_html( $args['title'] ) . html_entity_decode( $args['after_title'] ) . "\n"; }
$html .= '<div class="team-members component' . esc_attr( $class ) . '">' . "\n";
// Begin templating logic.
$tpl = '<div itemscope itemtype="http://schema.org/Person" class="%%CLASS%%">%%AVATAR%% %%TITLE%% <div id="team-member-%%ID%%" class="team-member-text" itemprop="description">%%TEXT%% %%AUTHOR%%</div></div>';
$tpl = apply_filters( 'woothemes_our_team_item_template', $tpl, $args );
$count = 0;
foreach ( $query as $post ) {
$count++;
$template = $tpl;
$css_class = apply_filters( 'woothemes_our_team_member_class', $css_class = 'team-member' );
if ( ( is_numeric( $args['per_row'] ) && ( 0 == ( $count - 1 ) % $args['per_row'] ) ) || 1 == $count ) { $css_class .= ' first'; }
if ( ( is_numeric( $args['per_row'] ) && ( 0 == $count % $args['per_row'] ) ) ) { $css_class .= ' last'; }
// Add a CSS class if no image is available.
if ( isset( $post->image ) && ( '' == $post->image ) ) {
$css_class .= ' no-image';
}
setup_postdata( $post );
$title = '';
$title_name = '';
// If we need to display the title, get the data
if ( ( get_the_title( $post ) != '' ) && true == $args['display_author'] ) {
$title .= '<h3 itemprop="name" class="member">';
if ( true == $args['display_url'] && '' != $post->url && apply_filters( 'woothemes_our_team_member_url', true ) ) {
$title .= '<a href="' . esc_url( $post->url ) . '">' . "\n";
}
$title_name = get_the_title( $post );
$title .= $title_name;
if ( true == $args['display_url'] && '' != $post->url && apply_filters( 'woothemes_our_team_member_url', true ) ) {
$title .= '</a>' . "\n";
}
$title .= '</h3><!--/.member-->' . "\n";
$member_role = '';
if ( true == $args['display_role'] && isset( $post->byline ) && '' != $post->byline && apply_filters( 'woothemes_our_team_member_role', true ) ) {
$member_role .= ' <p class="role" itemprop="jobTitle">' . $post->byline . '</p><!--/.excerpt-->' . "\n";
}
$title .= apply_filters( 'woothemes_our_team_member_fields_display', $member_role );
}
// Templating engine replacement.
$template = str_replace( '%%TITLE%%', $title, $template );
$author = '';
$author_text = '';
$user = $post->user_id;
// If we need to display the author, get the data.
if ( true == $args['display_additional'] ) {
$author .= '<ul class="author-details">';
$member_fields = '';
if ( true == $args['display_author_archive'] && apply_filters( 'woothemes_our_team_member_user_id', true ) ) {
// User didn't select an item from the autocomplete list
// Let's try to get the user from the search query
if ( 0 == $post->user_id && '' != $post->user_search ) {
$user = get_user_by( 'slug', $post->user_search );
if ( $user ) {
$user = $user->ID;
}
}
if ( 0 != $user ) {
$member_fields .= '<li class="our-team-author-archive" itemprop="url">' . sprintf( __( 'Read posts by %1$s', 'our-team-by-woothemes' ), get_the_title() ) . '</li>' . "\n";
}
}
if ( true == $args['contact_email'] && '' != $post->contact_email && apply_filters( 'woothemes_our_team_member_contact_email', true ) ) {
$member_fields .= '<li class="our-team-contact-email" itemprop="email">' . __( 'Email me ', 'our-team-by-woothemes' ) . '</li>';
}
if ( true == $args['tel'] && '' != $post->tel && apply_filters( 'woothemes_our_team_member_tel', true ) ) {
$call_protocol = apply_filters( 'woothemes_our_team_call_protocol', $protocol = 'tel' );
$member_fields .= '<li class="our-team-tel" itemprop="telephone"><span>' . __( 'Tel: ', 'our-team-by-woothemes' ) . '</span>' . esc_html( $post->tel ) . '</li>';
}
if ( true == $args['display_twitter'] && '' != $post->twitter && apply_filters( 'woothemes_our_team_member_twitter', true ) ) {
$member_fields .= '<li class="our-team-twitter" itemprop="contactPoint">Follow #' . esc_html( $post->twitter ) . '<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?"http":"https";if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document, "script", "twitter-wjs");</script></li>' . "\n";
}
$author .= apply_filters( 'woothemes_our_member_fields_display', $member_fields );
$author .= '</ul>';
// Templating engine replacement.
$template = str_replace( '%%AUTHOR%%', $author, $template );
} else {
$template = str_replace( '%%AUTHOR%%', '', $template );
}
// Templating logic replacement.
$template = str_replace( '%%ID%%', get_the_ID(), $template );
$template = str_replace( '%%CLASS%%', esc_attr( $css_class ), $template );
if ( isset( $post->image ) && ( '' != $post->image ) && true == $args['display_avatar'] ) {
$template = str_replace( '%%AVATAR%%', '<figure itemprop="image">' . $post->image . '</figure>', $template );
} else {
$template = str_replace( '%%AVATAR%%', '', $template );
}
// Remove any remaining %%AVATAR%% template tags.
$template = str_replace( '%%AVATAR%%', '', $template );
$real_more = $more;
$more = 0;
$content = apply_filters( 'woothemes_our_team_content', wpautop( get_the_content( __( 'Read full biography...', 'our-team-by-woothemes' ) ) ), $post );
$more = $real_more;
// Display bio if Team Member is mapped to a user on this site.
if ( apply_filters( 'woothemes_our_team_display_bio', true ) && 0 != $user ) {
if ( '' != get_the_author_meta( 'description', $user ) ) {
$content = wpautop( get_the_author_meta( 'description', $user ) );
}
}
$template = str_replace( '%%TEXT%%', $content, $template );
// filter the individual team member html
$template = apply_filters( 'woothemes_our_team_member_html', $template, $post );
// Assign for output.
$html .= $template;
}
wp_reset_postdata();
if ( $args['pagination'] == true && count( $query ) > 1 && $args['effect'] != 'none' ) {
$html .= '<div class="pagination">' . "\n";
$html .= '' . apply_filters( 'woothemes_our_team_prev_btn', '← ' . __( 'Previous', 'our-team-by-woothemes' ) ) . '' . "\n";
$html .= '' . apply_filters( 'woothemes_our_team_next_btn', __( 'Next', 'our-team-by-woothemes' ) . ' →' ) . '' . "\n";
$html .= '</div><!--/.pagination-->' . "\n";
}
$html .= '</div><!--/.team-members-->' . "\n";
$html .= $args['after'] . "\n";
}
// Allow child themes/plugins to filter here.
$html = apply_filters( 'woothemes_our_team_html', $html, $query, $args );
if ( $args['echo'] != true ) {
return $html;
}
// Should only run is "echo" is set to true.
echo $html;
do_action( 'woothemes_our_team_after', $args ); // Only if "echo" is set to true.
} // End woothemes_our_team()
}
if ( ! function_exists( 'woothemes_our_team_shortcode' ) ) {
/**
* The shortcode function.
* #since 1.0.0
* #param array $atts Shortcode attributes.
* #param string $content If the shortcode is a wrapper, this is the content being wrapped.
* #return string Output using the template tag.
*/
function woothemes_our_team_shortcode ( $atts, $content = null ) {
$args = (array)$atts;
$defaults = array(
'limit' => 12,
'per_row' => null,
'orderby' => 'menu_order',
'order' => 'DESC',
'id' => 0,
'slug' => null,
'display_author' => true,
'display_additional' => true,
'display_avatar' => true,
'display_url' => true,
'display_author_archive' => true,
'display_twitter' => true,
'display_role' => true,
'effect' => 'fade', // Options: 'fade', 'none'
'pagination' => false,
'echo' => true,
'size' => 250,
'category' => 0,
'title' => '',
'before_title' => '<h2>',
'after_title' => '</h2>'
);
$args = shortcode_atts( $defaults, $atts );
// Make sure we return and don't echo.
$args['echo'] = false;
// Fix integers.
if ( isset( $args['limit'] ) ) {
$args['limit'] = intval( $args['limit'] );
}
if ( isset( $args['size'] ) && ( 0 < intval( $args['size'] ) ) ) {
$args['size'] = intval( $args['size'] );
}
if ( isset( $args['category'] ) && is_numeric( $args['category'] ) ) {
$args['category'] = intval( $args['category'] );
}
// Fix booleans.
foreach ( array( 'display_author', 'display_additional', 'display_url', 'display_author_archive', 'display_twitter', 'display_role', 'pagination', 'display_avatar' ) as $k => $v ) {
if ( isset( $args[$v] ) && ( 'true' == $args[$v] ) ) {
$args[$v] = true;
} else {
$args[$v] = false;
}
}
return woothemes_our_team( $args );
} // End woothemes_our_team_shortcode()
}
add_shortcode( 'woothemes_our_team', 'woothemes_our_team_shortcode' );
if ( ! function_exists( 'woothemes_our_team_content_default_filters' ) ) {
/**
* Adds default filters to the "woothemes_our_team_content" filter point.
* #since 1.0.0
* #return void
*/
function woothemes_our_team_content_default_filters () {
add_filter( 'woothemes_our_team_content', 'do_shortcode' );
} // End woothemes_our_team_content_default_filters()
add_action( 'woothemes_our_team_before', 'woothemes_our_team_content_default_filters' );
}
add_filter( 'the_content', 'woothemes_our_team_content' );
/**
* Display team member data on single / archive pages
* #since 1.4.0
* #return $content the post content
*/
function woothemes_our_team_content( $content ) {
global $post;
$team_member_email = esc_attr( get_post_meta( $post->ID, '_gravatar_email', true ) );
$user = esc_attr( get_post_meta( $post->ID, '_user_id', true ) );
$user_search = esc_attr( get_post_meta( $post->ID, '_user_search', true ) );
$twitter = esc_attr( get_post_meta( $post->ID, '_twitter', true ) );
$role = esc_attr( get_post_meta( $post->ID, '_byline', true ) );
$url = esc_attr( get_post_meta( $post->ID, '_url', true ) );
$tel = esc_attr( get_post_meta( $post->ID, '_tel', true ) );
$contact_email = esc_attr( get_post_meta( $post->ID, '_contact_email', true ) );
if ( 'team-member' == get_post_type() ) {
$team_member_gravatar = '';
$team_member_role = '';
$member_fields = '';
$author = '';
if ( isset( $team_member_email ) && ( '' != $team_member_email ) ) {
$team_member_gravatar = '<figure itemprop="image">' . get_avatar( $team_member_email, 250 ) . '</figure>';
}
if ( isset( $role ) && '' != $role && apply_filters( 'woothemes_our_team_member_role', true ) ) {
$team_member_role .= ' <p class="role" itemprop="jobTitle">' . $role . '</p>' . "\n";
}
$author .= '<ul class="author-details">';
if ( apply_filters( 'woothemes_our_team_member_user_id', true ) ) {
if ( 0 == $user && '' != $user_search ) {
$user = get_user_by( 'slug', $user_search );
if ( $user ) {
$user = $user;
}
}
if ( 0 != $user ) {
$member_fields .= '<li class="our-team-author-archive" itemprop="url">' . sprintf( __( 'Read posts by %1$s', 'woothemes' ), get_the_title() ) . '</li>' . "\n";
}
}
if ( '' != $tel && apply_filters( 'woothemes_our_team_member_contact_email', true ) ) {
$member_fields .= '<li class="our-team-contact-email" itemprop="email">' . __( 'Email ', 'our-team-by-woothemes' ) . get_the_title() . '</li>';
}
if ( '' != $tel && apply_filters( 'woothemes_our_team_member_tel', true ) ) {
$call_protocol = apply_filters( 'woothemes_our_team_call_protocol', $protocol = 'tel' );
$member_fields .= '<li class="our-team-tel" itemprop="telephone"><span>' . __( 'Tel: ', 'our-team-by-woothemes' ) . '</span>' . $tel . '</li>';
}
if ( '' != $twitter && apply_filters( 'woothemes_our_team_member_twitter', true ) ) {
$member_fields .= '<li class="our-team-twitter" itemprop="contactPoint">Follow #' . esc_html( $twitter ) . '<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?"http":"https";if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document, "script", "twitter-wjs");</script></li>' . "\n";
}
$author .= apply_filters( 'woothemes_our_member_fields_display', $member_fields );
$author .= '</ul>';
return $team_member_gravatar . $team_member_role . $content . $author;
} else {
return $content;
}
}
You can filter the template:
function so_27863277_our_team_template( $tpl, $args ){
$tpl = '<div itemscope itemtype="http://schema.org/Person" class="%%CLASS%%">%%AVATAR%% %%TITLE%% Read About Me<div id="team-member-%%ID%%" class="team-member-text" itemprop="description">%%TEXT%% %%AUTHOR%%</div></div>';
return $tpl;
}
add_filter( 'woothemes_our_team_item_template', 'so_27863277_our_team_template', 10, 2 );
Then by default, you might also want to style the team-member-text div so that it is hidden.
.team-member-text{ display: none; }
I'm not sure how to make it work with your particular lightbox plugin so you will have to adapt that part yourself.

Categories