Version Description
- Added Import & Export tools
- Fixes and cleanup
Download this release
Release Info
Developer | smartcat |
Plugin | Our Team Showcase |
Version | 4.3.0 |
Comparing to | |
See all releases |
Code changes from version 4.2.0 to 4.3.0
- assets/admin/css/admin.css +10 -0
- assets/admin/js/settings.js +21 -0
- constants.php +12 -1
- includes/TeamMember.php +18 -0
- includes/admin-settings.php +14 -2
- includes/documentation.php +51 -3
- includes/helpers.php +1 -1
- includes/tools.php +494 -0
- our-team-showcase.php +2 -1
- readme.txt +7 -2
assets/admin/css/admin.css
CHANGED
@@ -186,4 +186,14 @@ input:checked + .slider:before {
|
|
186 |
|
187 |
.slider.round:before {
|
188 |
border-radius: 50%;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
}
|
186 |
|
187 |
.slider.round:before {
|
188 |
border-radius: 50%;
|
189 |
+
}
|
190 |
+
|
191 |
+
.tool-status-failed,
|
192 |
+
.tool-status-failed th{
|
193 |
+
color: red !important;
|
194 |
+
}
|
195 |
+
|
196 |
+
.tool-status-success,
|
197 |
+
.tool-status-success th {
|
198 |
+
color: green !important;
|
199 |
}
|
assets/admin/js/settings.js
CHANGED
@@ -1,5 +1,26 @@
|
|
1 |
jQuery(document).ready(function ($) {
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
var limit = $('#ots-display-limit-number');
|
4 |
|
5 |
|
1 |
jQuery(document).ready(function ($) {
|
2 |
|
3 |
+
// ---------- Tools //
|
4 |
+
$( '#ots-import-form' ).submit( function() {
|
5 |
+
// alert()
|
6 |
+
if( $( '#ots-import-replace-button' ).val() === 'Import & Replace Existing' ) {
|
7 |
+
|
8 |
+
var r
|
9 |
+
|
10 |
+
r = confirm( 'This will delete all your team members' )
|
11 |
+
|
12 |
+
if( r == true ) {
|
13 |
+
return true
|
14 |
+
}else {
|
15 |
+
return false
|
16 |
+
}
|
17 |
+
|
18 |
+
}
|
19 |
+
|
20 |
+
|
21 |
+
})
|
22 |
+
// -------------------
|
23 |
+
|
24 |
var limit = $('#ots-display-limit-number');
|
25 |
|
26 |
|
constants.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
namespace ots;
|
4 |
|
5 |
-
const VERSION = '4.
|
6 |
|
7 |
|
8 |
interface Options {
|
@@ -82,6 +82,17 @@ interface Options {
|
|
82 |
*/
|
83 |
const NUKE = 'ots-nuke-install';
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
}
|
86 |
|
87 |
interface Defaults {
|
2 |
|
3 |
namespace ots;
|
4 |
|
5 |
+
const VERSION = '4.3.0';
|
6 |
|
7 |
|
8 |
interface Options {
|
82 |
*/
|
83 |
const NUKE = 'ots-nuke-install';
|
84 |
|
85 |
+
|
86 |
+
/**
|
87 |
+
* @since 4.3.0
|
88 |
+
*/
|
89 |
+
const EXPORT_BUTTON = 'ots-export-button';
|
90 |
+
|
91 |
+
/**
|
92 |
+
* @since 4.3.0
|
93 |
+
*/
|
94 |
+
const IMPORT_BUTTON = 'ots-import-button';
|
95 |
+
|
96 |
}
|
97 |
|
98 |
interface Defaults {
|
includes/TeamMember.php
CHANGED
@@ -85,6 +85,24 @@ class TeamMember {
|
|
85 |
return get_the_terms( get_post( $this->get_id() ), 'team_member_position' );
|
86 |
|
87 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
|
90 |
public function in_group( $id ) {
|
85 |
return get_the_terms( get_post( $this->get_id() ), 'team_member_position' );
|
86 |
|
87 |
}
|
88 |
+
|
89 |
+
public function set_name( $name ) {
|
90 |
+
|
91 |
+
wp_update_post( array(
|
92 |
+
'ID' => $this->get_id(),
|
93 |
+
'post_title' => $name
|
94 |
+
) );
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
public function set_bio( $bio ) {
|
99 |
+
|
100 |
+
wp_update_post( array(
|
101 |
+
'ID' => $this->get_id(),
|
102 |
+
'post_content' => $bio
|
103 |
+
) );
|
104 |
+
|
105 |
+
}
|
106 |
|
107 |
|
108 |
public function in_group( $id ) {
|
includes/admin-settings.php
CHANGED
@@ -37,6 +37,7 @@ function add_menu_pages() {
|
|
37 |
|
38 |
add_submenu_page( 'edit.php?post_type=team_member', __( 'Re-Order Members', 'ots' ), __( 'Re-Order Members', 'ots' ), 'manage_options', 'ots-reorder-members', 'ots\do_member_reorder_page' );
|
39 |
add_submenu_page( 'edit.php?post_type=team_member', __( 'Our Team Settings', 'ots' ), __( 'Settings', 'ots' ), 'manage_options', 'ots-settings', 'ots\do_settings_page' );
|
|
|
40 |
|
41 |
}
|
42 |
|
@@ -433,7 +434,7 @@ function do_settings_page() {
|
|
433 |
$tabs = apply_filters( 'ots_settings_page_tabs', array(
|
434 |
'ots-team-view' => __( 'Team View', 'ots' ),
|
435 |
'ots-single-member-view' => __( 'Single Member View', 'ots' ),
|
436 |
-
'ots-advanced' => __( 'Advanced', 'ots' )
|
437 |
) );
|
438 |
|
439 |
reset( $tabs );
|
@@ -517,6 +518,16 @@ function do_settings_page() {
|
|
517 |
|
518 |
<div class="sidebar">
|
519 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
520 |
<div class="widget">
|
521 |
<h2><?php _e( 'Quick Reference', 'ots' ); ?></h2>
|
522 |
<div class="content">
|
@@ -790,4 +801,5 @@ function settings_toggle( array $args ) {
|
|
790 |
echo ' /><span class="slider ' . esc_attr( $args['slider'] ) . '"></label> ';
|
791 |
echo '<span class="label">' . esc_html( $args['label'] ) . '</span>';
|
792 |
|
793 |
-
}
|
|
37 |
|
38 |
add_submenu_page( 'edit.php?post_type=team_member', __( 'Re-Order Members', 'ots' ), __( 'Re-Order Members', 'ots' ), 'manage_options', 'ots-reorder-members', 'ots\do_member_reorder_page' );
|
39 |
add_submenu_page( 'edit.php?post_type=team_member', __( 'Our Team Settings', 'ots' ), __( 'Settings', 'ots' ), 'manage_options', 'ots-settings', 'ots\do_settings_page' );
|
40 |
+
add_submenu_page( 'edit.php?post_type=team_member', __( 'Our Team Import/Export', 'ots' ), __( 'Import/Export', 'ots' ), 'manage_options', 'ots-import-export', 'ots\do_import_export_page' );
|
41 |
|
42 |
}
|
43 |
|
434 |
$tabs = apply_filters( 'ots_settings_page_tabs', array(
|
435 |
'ots-team-view' => __( 'Team View', 'ots' ),
|
436 |
'ots-single-member-view' => __( 'Single Member View', 'ots' ),
|
437 |
+
'ots-advanced' => __( 'Advanced', 'ots' ),
|
438 |
) );
|
439 |
|
440 |
reset( $tabs );
|
518 |
|
519 |
<div class="sidebar">
|
520 |
|
521 |
+
<div class="widget">
|
522 |
+
<h2><?php _e( 'We need your help!', 'ots' ); ?></h2>
|
523 |
+
<div class="content">
|
524 |
+
<ul>
|
525 |
+
<li><?php _e( 'Do you like this plugin ? Please take 1 minute and leave us a 5-star review. Your support of this plugin means more features and improvements!', 'ots' ); ?></li>
|
526 |
+
<li><a href="https://wordpress.org/support/plugin/our-team-enhanced/reviews/#new-post" target="_BLANK"><?php _e( 'Click here to leave a review.', 'ots' ); ?></a></li>
|
527 |
+
</ul>
|
528 |
+
</div>
|
529 |
+
</div>
|
530 |
+
|
531 |
<div class="widget">
|
532 |
<h2><?php _e( 'Quick Reference', 'ots' ); ?></h2>
|
533 |
<div class="content">
|
801 |
echo ' /><span class="slider ' . esc_attr( $args['slider'] ) . '"></label> ';
|
802 |
echo '<span class="label">' . esc_html( $args['label'] ) . '</span>';
|
803 |
|
804 |
+
}
|
805 |
+
|
includes/documentation.php
CHANGED
@@ -31,7 +31,11 @@ function add_documentation_sections() {
|
|
31 |
add_settings_section( 'manage-members', __( 'Managing Members', 'ots-pro' ), '', 'ots-portal' );
|
32 |
add_settings_section( 'restrict-posts', __( 'Restricting Posts and Pages', 'ots-pro' ), '', 'ots-portal' );
|
33 |
add_settings_section( 'portal-usage', __( 'Using the Community Hub', 'ots-pro' ), '', 'ots-portal' );
|
|
|
|
|
|
|
34 |
|
|
|
35 |
}
|
36 |
|
37 |
add_action( 'admin_init', 'ots\add_documentation_sections' );
|
@@ -63,6 +67,9 @@ function add_documentation_fields() {
|
|
63 |
add_settings_field( 'editing-profile', __( 'Editing Your Profile', 'ots-pro' ), 'ots\doc_editing_profile', 'ots-portal', 'portal-usage' );
|
64 |
add_settings_field( 'viewing-profile', __( 'Viewing Others Profiles', 'ots-pro' ), 'ots\doc_viewing_profile', 'ots-portal', 'portal-usage' );
|
65 |
add_settings_field( 'reset-password', __( 'Resetting Your Password', 'ots-pro' ), 'ots\doc_reset_password', 'ots-portal', 'portal-usage' );
|
|
|
|
|
|
|
66 |
|
67 |
}
|
68 |
|
@@ -460,6 +467,45 @@ function doc_viewing_profile() { ?>
|
|
460 |
<?php }
|
461 |
|
462 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
463 |
/**
|
464 |
* Render the documentation page.
|
465 |
*
|
@@ -469,7 +515,8 @@ function do_documentation_page() {
|
|
469 |
|
470 |
$tabs = array(
|
471 |
'ots-getting-started' => __( 'Getting Started', 'ots' ),
|
472 |
-
'ots-portal' => __( 'Community Hub', 'ots-pro' )
|
|
|
473 |
);
|
474 |
|
475 |
$tabs = apply_filters( 'ots_documentation_tabs', $tabs );
|
@@ -489,7 +536,7 @@ function do_documentation_page() {
|
|
489 |
<div class="inner">
|
490 |
|
491 |
<div class="branding">
|
492 |
-
<img src="<?php echo esc_url( asset( 'images/branding/smartcat-medium.
|
493 |
</div>
|
494 |
|
495 |
<p class="page-title"><?php _e( 'Our Team Showcase', 'ots' ); ?></p>
|
@@ -543,4 +590,5 @@ function do_documentation_page() {
|
|
543 |
|
544 |
</div>
|
545 |
|
546 |
-
<?php }
|
|
31 |
add_settings_section( 'manage-members', __( 'Managing Members', 'ots-pro' ), '', 'ots-portal' );
|
32 |
add_settings_section( 'restrict-posts', __( 'Restricting Posts and Pages', 'ots-pro' ), '', 'ots-portal' );
|
33 |
add_settings_section( 'portal-usage', __( 'Using the Community Hub', 'ots-pro' ), '', 'ots-portal' );
|
34 |
+
|
35 |
+
add_settings_section( 'export-general', __( 'Exporting Team Members', 'ots-pro' ), '', 'ots-import-export' );
|
36 |
+
add_settings_section( 'import-general', __( 'Importing Team Members', 'ots-pro' ), '', 'ots-import-export' );
|
37 |
|
38 |
+
|
39 |
}
|
40 |
|
41 |
add_action( 'admin_init', 'ots\add_documentation_sections' );
|
67 |
add_settings_field( 'editing-profile', __( 'Editing Your Profile', 'ots-pro' ), 'ots\doc_editing_profile', 'ots-portal', 'portal-usage' );
|
68 |
add_settings_field( 'viewing-profile', __( 'Viewing Others Profiles', 'ots-pro' ), 'ots\doc_viewing_profile', 'ots-portal', 'portal-usage' );
|
69 |
add_settings_field( 'reset-password', __( 'Resetting Your Password', 'ots-pro' ), 'ots\doc_reset_password', 'ots-portal', 'portal-usage' );
|
70 |
+
|
71 |
+
add_settings_field( 'export-basics', __( 'Export Team Members', 'ots-pro' ), 'ots\doc_export_team', 'ots-import-export', 'export-general' );
|
72 |
+
add_settings_field( 'import-basics', __( 'Import Team Members', 'ots-pro' ), 'ots\doc_import_team', 'ots-import-export', 'import-general' );
|
73 |
|
74 |
}
|
75 |
|
467 |
<?php }
|
468 |
|
469 |
|
470 |
+
function doc_export_team() { ?>
|
471 |
+
|
472 |
+
<div>
|
473 |
+
<p><?php _e( 'The Export feature allows you to export all your team data to a CSV file. This allows you to view the team members in Excel - as well as migrate the team data to a different site or software that you may be using.', 'ots' ); ?></p>
|
474 |
+
<p><?php _e( 'To use this feature, go to Import/Export menu item under Team and click the Export button. The plugin will generate an export file and store it in the Uploads folder. You can click the Download button to download a copy of the file.', 'ots' ); ?></p>
|
475 |
+
</div>
|
476 |
+
|
477 |
+
<?php }
|
478 |
+
|
479 |
+
function doc_import_team() { ?>
|
480 |
+
|
481 |
+
<div>
|
482 |
+
<p><?php _e( 'The Import feature allows you to import team members from a csv file. For companies with large staff directories this can be a very effective way of bulk adding new members to the team.', 'ots' ); ?></p>
|
483 |
+
<p><?php _e( 'To use this feature, go to Import/Export menu item under Team, select the CSV file that contains your team member data from your computer and click the Import button.', 'ots' ); ?></p>
|
484 |
+
|
485 |
+
<p>
|
486 |
+
<a href="https://raw.githubusercontent.com/smartcatdev/docs/master/ots/demo-data.csv" class="button button-primary" download><?php _e( 'Download Sample CSV', 'ots' ); ?></a>
|
487 |
+
</p>
|
488 |
+
|
489 |
+
|
490 |
+
<h3><?php _e( 'Important notes', 'ots' ); ?></h3>
|
491 |
+
|
492 |
+
<p>
|
493 |
+
<?php _e( '1. Please note that the Import tool will attempt to import member images, this requires the plugin to '
|
494 |
+
. 'create the image files on the destination website - the web server must have access to create files in PHP '
|
495 |
+
. 'otherwise the import will fail', 'ots' ); ?>
|
496 |
+
</p>
|
497 |
+
<p>
|
498 |
+
<?php _e( '2. The Import feature will not import posts from the "Favorite articles" - It will simply assign the member\'s favorite posts to the IDs', 'ots' ); ?>
|
499 |
+
</p>
|
500 |
+
|
501 |
+
<p>
|
502 |
+
<?php _e( '3. The Import feature will not import member groups, or attempt to create them. This is mainly for team member only at this time.', 'ots' ); ?>
|
503 |
+
</p>
|
504 |
+
|
505 |
+
</div>
|
506 |
+
|
507 |
+
<?php }
|
508 |
+
|
509 |
/**
|
510 |
* Render the documentation page.
|
511 |
*
|
515 |
|
516 |
$tabs = array(
|
517 |
'ots-getting-started' => __( 'Getting Started', 'ots' ),
|
518 |
+
'ots-portal' => __( 'Community Hub', 'ots-pro' ),
|
519 |
+
'ots-import-export' => __( 'Import & Export', 'ots-pro' )
|
520 |
);
|
521 |
|
522 |
$tabs = apply_filters( 'ots_documentation_tabs', $tabs );
|
536 |
<div class="inner">
|
537 |
|
538 |
<div class="branding">
|
539 |
+
<img src="<?php echo esc_url( asset( 'images/branding/smartcat-medium.png' ) ); ?>" />
|
540 |
</div>
|
541 |
|
542 |
<p class="page-title"><?php _e( 'Our Team Showcase', 'ots' ); ?></p>
|
590 |
|
591 |
</div>
|
592 |
|
593 |
+
<?php }
|
594 |
+
|
includes/helpers.php
CHANGED
@@ -158,4 +158,4 @@ function member_groups( $member = null, $separator = ' - ', $echo = true ) {
|
|
158 |
|
159 |
return $str;
|
160 |
|
161 |
-
}
|
158 |
|
159 |
return $str;
|
160 |
|
161 |
+
}
|
includes/tools.php
ADDED
@@ -0,0 +1,494 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace ots;
|
4 |
+
|
5 |
+
add_action( 'admin_post_ots_export_team', function() {
|
6 |
+
|
7 |
+
$message = array();
|
8 |
+
|
9 |
+
$team = new \WP_Query( array(
|
10 |
+
'post_type' => 'team_member',
|
11 |
+
'post_status' => 'publish'
|
12 |
+
) );
|
13 |
+
|
14 |
+
|
15 |
+
if( $team->post_count <= 0 ) {
|
16 |
+
|
17 |
+
$message['export_response'] = 'Failed';
|
18 |
+
$message['export_output'] = urlencode( 'There are no team members to export' );
|
19 |
+
|
20 |
+
}else {
|
21 |
+
|
22 |
+
|
23 |
+
$members = array();
|
24 |
+
|
25 |
+
foreach( $team->posts as $member ) {
|
26 |
+
|
27 |
+
$member = team_member( $member->ID );
|
28 |
+
|
29 |
+
$members[ $member->get_id() ] = array(
|
30 |
+
'name' => $member->get_name(),
|
31 |
+
'title' => $member->title,
|
32 |
+
'bio' => $member->get_bio(),
|
33 |
+
'photo_url' => get_the_post_thumbnail_url( $member->get_id() ),
|
34 |
+
'email' => $member->email,
|
35 |
+
'phone' => $member->phone,
|
36 |
+
'facebook' => $member->facebook,
|
37 |
+
'twitter' => $member->twitter,
|
38 |
+
'linkedin' => $member->linkedin,
|
39 |
+
'instagram' => $member->instagram,
|
40 |
+
'pinterest' => $member->pinterest,
|
41 |
+
'gplus' => $member->gplus,
|
42 |
+
'website' => $member->website,
|
43 |
+
'other_icon' => $member->other_icon,
|
44 |
+
'other' => $member->other,
|
45 |
+
'article_bool' => $member->article_bool,
|
46 |
+
'article_title' => $member->article_title,
|
47 |
+
'article1' => $member->article1,
|
48 |
+
'article2' => $member->article2,
|
49 |
+
'article3' => $member->article3,
|
50 |
+
'skill_bool' => $member->skill_bool,
|
51 |
+
'skill_title' => $member->skill_title,
|
52 |
+
'skill1' => $member->skill1,
|
53 |
+
'skill_value1' => $member->skill_value1,
|
54 |
+
'skill2' => $member->skill2,
|
55 |
+
'skill_value2' => $member->skill_value2,
|
56 |
+
'skill3' => $member->skill3,
|
57 |
+
'skill_value3' => $member->skill_value3,
|
58 |
+
'skill4' => $member->skill4,
|
59 |
+
'skill_value4' => $member->skill_value4,
|
60 |
+
'skill5' => $member->skill5,
|
61 |
+
'skill_value5' => $member->skill_value5,
|
62 |
+
'tags_bool' => $member->tags_bool,
|
63 |
+
'tags_title' => $member->tags_title,
|
64 |
+
'tags' => $member->tags,
|
65 |
+
'quote' => $member->quote,
|
66 |
+
);
|
67 |
+
|
68 |
+
}
|
69 |
+
|
70 |
+
$csv = put_csv( $members );
|
71 |
+
|
72 |
+
$dir = wp_upload_dir();
|
73 |
+
$file_path = $dir['path'] . '/export.csv';
|
74 |
+
|
75 |
+
|
76 |
+
|
77 |
+
if( create_file( $file_path, $csv ) ) {
|
78 |
+
|
79 |
+
$message['export_response'] = 'Success!';
|
80 |
+
$message['export_output'] = $dir['url'] . '/export.csv';
|
81 |
+
|
82 |
+
}else {
|
83 |
+
|
84 |
+
$message['export_response'] = 'Failed';
|
85 |
+
$message['export_output'] = urlencode( 'Cannot create file, check your server permissions' );
|
86 |
+
$message['csv'] = $csv;
|
87 |
+
}
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
wp_safe_redirect( add_query_arg( $message, wp_get_referer() ) );
|
92 |
+
|
93 |
+
});
|
94 |
+
|
95 |
+
|
96 |
+
add_action( 'admin_post_ots_import_team', function() {
|
97 |
+
|
98 |
+
$message = array();
|
99 |
+
$total_imported = 0;
|
100 |
+
|
101 |
+
maybe_delete_members();
|
102 |
+
|
103 |
+
$accepted_mime_types = array(
|
104 |
+
'text/csv',
|
105 |
+
'text/comma-separated-values',
|
106 |
+
'text/plain',
|
107 |
+
'text/anytext',
|
108 |
+
'text/*',
|
109 |
+
'text/plain',
|
110 |
+
'text/anytext',
|
111 |
+
'text/*',
|
112 |
+
'application/csv',
|
113 |
+
'application/excel',
|
114 |
+
);
|
115 |
+
|
116 |
+
// Ensure user has selected an import file
|
117 |
+
if( empty( $_FILES['ots_file_import'] ) ) {
|
118 |
+
|
119 |
+
$message['import_response'] = 'Failed';
|
120 |
+
$message['import_output'] = urlencode( 'Missing import file.' );
|
121 |
+
wp_safe_redirect( add_query_arg( $message, wp_get_referer() ) );
|
122 |
+
return;
|
123 |
+
|
124 |
+
}
|
125 |
+
|
126 |
+
// Ensure the file is of the right type
|
127 |
+
if( empty( $_FILES['ots_file_import']['type'] ) || ! in_array( strtolower( $_FILES['ots_file_import']['type'] ), $accepted_mime_types ) ) {
|
128 |
+
|
129 |
+
$message['import_response'] = 'Failed';
|
130 |
+
$message['import_output'] = urlencode( 'The file you have uploaded cannot be processed. Please upload a CSV file.' );
|
131 |
+
wp_safe_redirect( add_query_arg( $message, wp_get_referer() ) );
|
132 |
+
return;
|
133 |
+
|
134 |
+
}
|
135 |
+
|
136 |
+
$upload = wp_upload_bits( $_FILES['ots_file_import']['name'], null, file_get_contents( $_FILES['ots_file_import']['tmp_name'] ) );
|
137 |
+
|
138 |
+
$data = read_csv( $upload['file'] );
|
139 |
+
|
140 |
+
|
141 |
+
foreach( $data as $row ) {
|
142 |
+
|
143 |
+
try {
|
144 |
+
|
145 |
+
$id = wp_insert_post( array(
|
146 |
+
'post_type' => 'team_member',
|
147 |
+
'post_status' => 'publish'
|
148 |
+
) );
|
149 |
+
|
150 |
+
} catch ( \Exception $ex ) {
|
151 |
+
|
152 |
+
continue;
|
153 |
+
|
154 |
+
}
|
155 |
+
|
156 |
+
$member = team_member( $id );
|
157 |
+
$total_imported++;
|
158 |
+
|
159 |
+
foreach( $row as $key => $val ) {
|
160 |
+
|
161 |
+
switch( $key ) {
|
162 |
+
|
163 |
+
case 'name' :
|
164 |
+
$member->set_name( $val );
|
165 |
+
break;
|
166 |
+
|
167 |
+
case 'photo_url' :
|
168 |
+
import_photo( $member, $val );
|
169 |
+
break;
|
170 |
+
|
171 |
+
case 'bio' :
|
172 |
+
$member->set_bio( $val );
|
173 |
+
break;
|
174 |
+
|
175 |
+
default :
|
176 |
+
$member->$key = $val;
|
177 |
+
break;
|
178 |
+
|
179 |
+
}
|
180 |
+
|
181 |
+
|
182 |
+
}
|
183 |
+
|
184 |
+
|
185 |
+
}
|
186 |
+
|
187 |
+
$message['import_response'] = 'Success';
|
188 |
+
$message['import_output'] = urlencode( 'Import successful! ' . $total_imported . ' member(s) imported' );
|
189 |
+
|
190 |
+
|
191 |
+
wp_safe_redirect( add_query_arg( $message, wp_get_referer() ) );
|
192 |
+
|
193 |
+
});
|
194 |
+
|
195 |
+
|
196 |
+
function import_photo( TeamMember $member, $photo_url ) {
|
197 |
+
|
198 |
+
if( ! $photo_url ) {
|
199 |
+
return;
|
200 |
+
}
|
201 |
+
|
202 |
+
$dir = wp_upload_dir();
|
203 |
+
|
204 |
+
$contents = file_get_contents( $photo_url );
|
205 |
+
$extension = substr( strrchr( $photo_url,'.' ), 1 );
|
206 |
+
$uploadfile = $dir['path'] . '/' . $member->get_id() . '.' . $extension;
|
207 |
+
|
208 |
+
$savefile = fopen( $uploadfile, 'w' );
|
209 |
+
fwrite( $savefile, $contents );
|
210 |
+
fclose( $savefile );
|
211 |
+
|
212 |
+
$attachment = array(
|
213 |
+
'post_title' => $member->get_id() . '.' . $extension,
|
214 |
+
'post_content' => '',
|
215 |
+
'post_mime_type' => get_mime_type( $extension ),
|
216 |
+
'post_status' => 'publish',
|
217 |
+
'post_parent' => $member->get_id()
|
218 |
+
);
|
219 |
+
|
220 |
+
$attach_id = wp_insert_attachment( $attachment, $uploadfile, $member->get_id() );
|
221 |
+
|
222 |
+
$attach_data = wp_generate_attachment_metadata( $attach_id, $uploadfile );
|
223 |
+
wp_update_attachment_metadata( $attach_id, $attach_data );
|
224 |
+
|
225 |
+
update_post_meta( $member->get_id(), '_thumbnail_id', $attach_id );
|
226 |
+
|
227 |
+
}
|
228 |
+
|
229 |
+
function get_mime_type( $extension ) {
|
230 |
+
|
231 |
+
$mime = null;
|
232 |
+
|
233 |
+
switch ( $extension ) {
|
234 |
+
|
235 |
+
case 'jpg' || 'jpeg' :
|
236 |
+
|
237 |
+
$mime = 'image/jpeg';
|
238 |
+
break;
|
239 |
+
|
240 |
+
case 'png' :
|
241 |
+
|
242 |
+
$mime = 'image/png';
|
243 |
+
break;
|
244 |
+
|
245 |
+
default :
|
246 |
+
|
247 |
+
$mime = 'image/jpeg';
|
248 |
+
break;
|
249 |
+
|
250 |
+
}
|
251 |
+
|
252 |
+
return $mime;
|
253 |
+
|
254 |
+
}
|
255 |
+
|
256 |
+
/**
|
257 |
+
*
|
258 |
+
* Creates a file at the specified location
|
259 |
+
*
|
260 |
+
* @param String $file_path
|
261 |
+
* @param String $contents
|
262 |
+
* @param String $mode
|
263 |
+
* @return boolean
|
264 |
+
* @throws Exception
|
265 |
+
*/
|
266 |
+
function create_file( $file_path, $contents, $mode = 'w' ) {
|
267 |
+
|
268 |
+
$file = fopen( $file_path, $mode );
|
269 |
+
|
270 |
+
if( ! $file ) {
|
271 |
+
return false;
|
272 |
+
}
|
273 |
+
|
274 |
+
fputs( $file, $contents );
|
275 |
+
fclose( $file );
|
276 |
+
|
277 |
+
return true;
|
278 |
+
|
279 |
+
}
|
280 |
+
|
281 |
+
function maybe_delete_members() {
|
282 |
+
|
283 |
+
if( isset( $_POST['ots-import-replace-button'] ) ) {
|
284 |
+
|
285 |
+
$team = new \WP_Query( array(
|
286 |
+
'post_type' => 'team_member'
|
287 |
+
) );
|
288 |
+
|
289 |
+
|
290 |
+
if( $team->post_count > 0 ) {
|
291 |
+
|
292 |
+
foreach( $team->posts as $member ) {
|
293 |
+
wp_delete_post( $member->ID );
|
294 |
+
}
|
295 |
+
|
296 |
+
}
|
297 |
+
|
298 |
+
}
|
299 |
+
|
300 |
+
|
301 |
+
|
302 |
+
}
|
303 |
+
|
304 |
+
function read_csv( $file_path, $mode = 'r' ) {
|
305 |
+
|
306 |
+
$array = array();
|
307 |
+
$fields = array();
|
308 |
+
$i=0;
|
309 |
+
|
310 |
+
$handle = fopen( $file_path, $mode );
|
311 |
+
|
312 |
+
while ( ( $row = fgetcsv( $handle, 4096 ) ) !== false) {
|
313 |
+
|
314 |
+
if ( empty( $fields ) ) {
|
315 |
+
$fields = $row;
|
316 |
+
continue;
|
317 |
+
}
|
318 |
+
|
319 |
+
foreach ($row as $k => $value ) {
|
320 |
+
|
321 |
+
$array[$i][$fields[$k]] = $value;
|
322 |
+
|
323 |
+
}
|
324 |
+
|
325 |
+
$i++;
|
326 |
+
}
|
327 |
+
|
328 |
+
if ( !feof( $handle ) ) {
|
329 |
+
|
330 |
+
echo "Error: unexpected fgets() fail\n";
|
331 |
+
|
332 |
+
}
|
333 |
+
|
334 |
+
fclose($handle);
|
335 |
+
|
336 |
+
return $array;
|
337 |
+
|
338 |
+
}
|
339 |
+
|
340 |
+
/**
|
341 |
+
*
|
342 |
+
* Takes associative array and returns a comma separated string
|
343 |
+
*
|
344 |
+
* @param type Array
|
345 |
+
* @return String
|
346 |
+
*/
|
347 |
+
function put_csv( $data ) {
|
348 |
+
|
349 |
+
$fh = fopen( 'php://temp', 'rw' );
|
350 |
+
|
351 |
+
fputcsv( $fh, array_keys( current( $data ) ) );
|
352 |
+
|
353 |
+
foreach ( $data as $row ) {
|
354 |
+
|
355 |
+
fputcsv( $fh, $row );
|
356 |
+
|
357 |
+
}
|
358 |
+
|
359 |
+
rewind( $fh );
|
360 |
+
$csv = stream_get_contents( $fh );
|
361 |
+
fclose( $fh );
|
362 |
+
|
363 |
+
return $csv;
|
364 |
+
|
365 |
+
}
|
366 |
+
|
367 |
+
function do_import_export_page() { ?>
|
368 |
+
|
369 |
+
<div class="wrap ots-admin-page">
|
370 |
+
|
371 |
+
<div class="ots-admin-header">
|
372 |
+
|
373 |
+
<div class="title-bar">
|
374 |
+
|
375 |
+
<div class="inner">
|
376 |
+
|
377 |
+
<div class="branding">
|
378 |
+
<img src="<?php echo esc_url( asset( 'images/branding/smartcat-medium.png' ) ); ?>" />
|
379 |
+
</div>
|
380 |
+
|
381 |
+
<p class="page-title"><?php _e( 'Our Team Showcase', 'ots' ); ?></p>
|
382 |
+
|
383 |
+
</div>
|
384 |
+
|
385 |
+
<?php if( apply_filters( 'ots_enable_pro_preview', true ) ) : ?>
|
386 |
+
|
387 |
+
<div class="inner">
|
388 |
+
|
389 |
+
<a href="http://wordpressteamplugin.com/templates/"
|
390 |
+
class="cta cta-secondary"
|
391 |
+
target="_blank">
|
392 |
+
<?php _e( 'View Demo', 'ots' ); ?>
|
393 |
+
</a>
|
394 |
+
|
395 |
+
<a href="https://smartcatdesign.net/downloads/our-team-showcase/"
|
396 |
+
class="cta cta-primary"
|
397 |
+
target="_blank">
|
398 |
+
<?php _e( 'Go Pro', 'ots' ); ?>
|
399 |
+
</a>
|
400 |
+
|
401 |
+
</div>
|
402 |
+
|
403 |
+
<?php endif; ?>
|
404 |
+
|
405 |
+
</div>
|
406 |
+
|
407 |
+
<div class="clear"></div>
|
408 |
+
|
409 |
+
</div>
|
410 |
+
|
411 |
+
<h2 style="display: none"></h2>
|
412 |
+
|
413 |
+
<div class="inner">
|
414 |
+
|
415 |
+
<div class="tabs-content" style="width: 75%">
|
416 |
+
|
417 |
+
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php?action=ots_export_team' ) ) ?>">
|
418 |
+
|
419 |
+
<h2><?php _e( 'Export', 'ots' ); ?></h2>
|
420 |
+
<table class="form-table">
|
421 |
+
<tbody>
|
422 |
+
<tr>
|
423 |
+
<th scope="row"><?php _e( 'Export Team Members', 'ots' ) ?></th>
|
424 |
+
<td>
|
425 |
+
<?php submit_button( __( 'Export', 'ots' ), 'secondary', 'ots-export-button', false, false ); ?>
|
426 |
+
</td>
|
427 |
+
</tr>
|
428 |
+
|
429 |
+
<?php $response = isset( $_GET['export_response'] ) ? $_GET['export_response'] : false; ?>
|
430 |
+
<?php if( $response ) : ?>
|
431 |
+
<tr class="tool-status-<?php echo esc_attr( strtolower( $response ) ); ?>">
|
432 |
+
<th><?php echo esc_attr( $response ); ?></th>
|
433 |
+
<td>
|
434 |
+
<?php if( $response == 'Failed' ) : ?>
|
435 |
+
<?php echo $_GET['export_output']; ?>
|
436 |
+
<?php else : ?>
|
437 |
+
<a href="<?php echo esc_url( $_GET['export_output'] ) ?>" class="button button-primary"><?php _e( 'Download', 'ots' ); ?></a>
|
438 |
+
<?php endif; ?>
|
439 |
+
|
440 |
+
|
441 |
+
</td>
|
442 |
+
</tr>
|
443 |
+
<?php endif; ?>
|
444 |
+
|
445 |
+
|
446 |
+
</tbody>
|
447 |
+
</table>
|
448 |
+
</form>
|
449 |
+
|
450 |
+
<form method="post" id="ots-import-form" action="<?php echo esc_url( admin_url( 'admin-post.php?action=ots_import_team' ) ) ?>" enctype="multipart/form-data">
|
451 |
+
|
452 |
+
<h2><?php _e( 'Import', 'ots' ); ?></h2>
|
453 |
+
<table class="form-table">
|
454 |
+
<tbody>
|
455 |
+
<tr>
|
456 |
+
<th scope="row"><?php _e( 'Import Team Members', 'ots' ) ?></th>
|
457 |
+
<td>
|
458 |
+
<input type="file" name="ots_file_import"/><br><br>
|
459 |
+
<?php submit_button( __( 'Import', 'ots' ), 'secondary', 'ots-import-button', false, false ); ?>
|
460 |
+
<?php submit_button( __( 'Import & Replace Existing', 'ots' ), 'primary', 'ots-import-replace-button', false, false ); ?>
|
461 |
+
</td>
|
462 |
+
</tr>
|
463 |
+
|
464 |
+
<?php $response = isset( $_GET['import_response'] ) ? $_GET['import_response'] : false; ?>
|
465 |
+
<?php if( $response ) : ?>
|
466 |
+
|
467 |
+
<tr class="tool-status-<?php echo esc_attr( strtolower( $response ) ); ?>">
|
468 |
+
<th><?php echo $response; ?></th>
|
469 |
+
<td><?php echo $_GET[ 'import_output' ] ?: ''; ?></td>
|
470 |
+
</tr>
|
471 |
+
|
472 |
+
<?php endif; ?>
|
473 |
+
|
474 |
+
|
475 |
+
<tr>
|
476 |
+
<td colspan="2">
|
477 |
+
<a href="<?php echo admin_url( 'edit.php?post_type=team_member&page=ots-docs&tab=ots-import-export' ); ?>"><?php _e( 'Click here', 'ots' ); ?></a> <?php _e( 'to learn more about uploading members and CSV file structure', 'ots' ) ?>
|
478 |
+
</td>
|
479 |
+
</tr>
|
480 |
+
|
481 |
+
</tbody>
|
482 |
+
</table>
|
483 |
+
</form>
|
484 |
+
|
485 |
+
</div>
|
486 |
+
|
487 |
+
|
488 |
+
<div class="clear"></div>
|
489 |
+
|
490 |
+
</div>
|
491 |
+
|
492 |
+
</div>
|
493 |
+
|
494 |
+
<?php }
|
our-team-showcase.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Our Team Showcase
|
4 |
* Plugin URI: https://smartcatdesign.net/downloads/our-team-showcase/
|
5 |
* Description: Display your team members in a very attractive way as a widget or page with the shortcode [our-team]
|
6 |
-
* Version: 4.
|
7 |
* Author: Smartcat
|
8 |
* Author URI: https://smartcatdesign.net
|
9 |
* License: GPL2
|
@@ -42,6 +42,7 @@ function init() {
|
|
42 |
include_once dirname( __FILE__ ) . '/includes/functions.php';
|
43 |
include_once dirname( __FILE__ ) . '/includes/helpers.php';
|
44 |
include_once dirname( __FILE__ ) . '/includes/team-member.php';
|
|
|
45 |
include_once dirname( __FILE__ ) . '/includes/admin-settings.php';
|
46 |
include_once dirname( __FILE__ ) . '/includes/documentation.php';
|
47 |
include_once dirname( __FILE__ ) . '/includes/add-ons.php';
|
3 |
* Plugin Name: Our Team Showcase
|
4 |
* Plugin URI: https://smartcatdesign.net/downloads/our-team-showcase/
|
5 |
* Description: Display your team members in a very attractive way as a widget or page with the shortcode [our-team]
|
6 |
+
* Version: 4.3.0
|
7 |
* Author: Smartcat
|
8 |
* Author URI: https://smartcatdesign.net
|
9 |
* License: GPL2
|
42 |
include_once dirname( __FILE__ ) . '/includes/functions.php';
|
43 |
include_once dirname( __FILE__ ) . '/includes/helpers.php';
|
44 |
include_once dirname( __FILE__ ) . '/includes/team-member.php';
|
45 |
+
include_once dirname( __FILE__ ) . '/includes/tools.php';
|
46 |
include_once dirname( __FILE__ ) . '/includes/admin-settings.php';
|
47 |
include_once dirname( __FILE__ ) . '/includes/documentation.php';
|
48 |
include_once dirname( __FILE__ ) . '/includes/add-ons.php';
|
readme.txt
CHANGED
@@ -4,10 +4,10 @@ Donate link: https://smartcatdesign.net/downloads/our-team-showcase/
|
|
4 |
Tags: team, staff, directory, employees, widget, shortcode, members, carousel, honeycomb, stack, grid, custom, template, social, profile, custom post type, portfolio, profile,meet team, skills, cv,v-card, portal
|
5 |
Requires at least: 4.6
|
6 |
Tested up to: 4.8.1
|
7 |
-
Stable tag: 4.
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
-
The best way to display your employees, team members, or any type of list. Multiple appealing templates,SEO friendly, re-order functionality
|
11 |
|
12 |
== Description ==
|
13 |
|
@@ -45,6 +45,7 @@ Available Customizations:
|
|
45 |
* Output your team members anywhere with the shortcode [our-team]
|
46 |
* Team Member contact info & links to social sites
|
47 |
* Favorite/Recommended content for each Team Member
|
|
|
48 |
* Easy to setup
|
49 |
|
50 |
Pro Version Features:
|
@@ -98,6 +99,10 @@ Team Member Details & Icons:
|
|
98 |
|
99 |
== Changelog ==
|
100 |
|
|
|
|
|
|
|
|
|
101 |
= 4.2.0 =
|
102 |
1. Added the ability to set the number of columns from the shortcode
|
103 |
2. Updated documentation
|
4 |
Tags: team, staff, directory, employees, widget, shortcode, members, carousel, honeycomb, stack, grid, custom, template, social, profile, custom post type, portfolio, profile,meet team, skills, cv,v-card, portal
|
5 |
Requires at least: 4.6
|
6 |
Tested up to: 4.8.1
|
7 |
+
Stable tag: 4.2.0
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
+
The best way to display your employees, team members, or any type of list. Multiple appealing templates,SEO friendly, re-order, import/export functionality
|
11 |
|
12 |
== Description ==
|
13 |
|
45 |
* Output your team members anywhere with the shortcode [our-team]
|
46 |
* Team Member contact info & links to social sites
|
47 |
* Favorite/Recommended content for each Team Member
|
48 |
+
* Ability to export and import team member data
|
49 |
* Easy to setup
|
50 |
|
51 |
Pro Version Features:
|
99 |
|
100 |
== Changelog ==
|
101 |
|
102 |
+
= 4.3.0 =
|
103 |
+
1. Added Import & Export tools
|
104 |
+
2. Fixes and cleanup
|
105 |
+
|
106 |
= 4.2.0 =
|
107 |
1. Added the ability to set the number of columns from the shortcode
|
108 |
2. Updated documentation
|