-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature - #NoID - Init master branch with current version in producti…
…on (1.3.2)
- Loading branch information
David DAUGREILH
committed
Dec 19, 2016
0 parents
commit c7e1325
Showing
31 changed files
with
3,593 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.multiselect { | ||
max-width: 500px; | ||
max-height:100px; | ||
overflow:auto; | ||
background-color: #ffffff; | ||
border: 1px solid #DDDDDD; | ||
margin-left: 20px; | ||
} | ||
|
||
.multiselect label { | ||
display:block; | ||
margin: 1px; | ||
} | ||
|
||
.multiselect-on { | ||
color:#ffffff; | ||
background-color:#BBBBBB; | ||
} | ||
|
||
.multiselect-off { | ||
color:#ffffff; | ||
background-color:#AAAAAA; | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
/** | ||
* Remember plugin path & URL | ||
*/ | ||
define( 'MUCD_PATH', plugin_basename( realpath( dirname( __FILE__ ).'/..') ) ); | ||
define( 'MUCD_COMPLETE_PATH', WP_PLUGIN_DIR.'/'.MUCD_PATH ); | ||
define( 'MUCD_URL', WP_PLUGIN_URL.'/'.MUCD_PATH ); | ||
|
||
/** | ||
* Domaine | ||
*/ | ||
define( 'MUCD_DOMAIN', 'multisite-clone-duplicator' ); | ||
|
||
/** | ||
* Slugs | ||
*/ | ||
define( 'MUCD_SLUG_NETWORK_ACTION', 'multisite-clone-duplicator' ); | ||
define( 'MUCD_SLUG_ACTION_DUPLICATE', 'duplicate-site' ); | ||
define( 'MUCD_SLUG_ACTION_SETTINGS', '_mucdsettings' ); | ||
|
||
/** | ||
* Site to excude | ||
*/ | ||
define( 'MUCD_SITE_DUPLICATION_EXCLUDE', '' ); | ||
|
||
/** | ||
* Environment constants | ||
*/ | ||
define( 'MUCD_PRIMARY_SITE_ID', 1 ); | ||
define( 'MUCD_MAX_NUMBER_OF_SITE', 5000 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
/** | ||
* ERRORS | ||
*/ | ||
define( 'MUCD_GAL_ERROR_CAPABILITIES', __( 'Sorry, you don\'t have permissions to use this page.', MUCD_DOMAIN ) ); | ||
define( 'MUCD_GAL_ERROR_NO_SITE', __( 'Sorry, there is no site available for duplication.', MUCD_DOMAIN ) ); | ||
define( 'MUCD_LOG_ERROR', __( 'The log file cannot be written', MUCD_DOMAIN ) ); | ||
define( 'MUCD_CANT_WRITE_LOG', __( 'The log file cannot be written to location', MUCD_DOMAIN ) ); | ||
define( 'MUCD_CHANGE_RIGHTS_LOG', __( 'To enable logging, change permissions on log directory', MUCD_DOMAIN ) ); | ||
|
||
/** | ||
* LABELS | ||
*/ | ||
define( 'MUCD_NETWORK_MENU_DUPLICATE', __( 'Duplicate', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_MENU_DUPLICATION', __( 'Duplication', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_DUPLICABLE', __( 'Duplicable', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_CUSTOMIZE', __( 'Customize', MUCD_DOMAIN ) ); | ||
define( 'MUCD_YES', __( 'Yes', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NO', __( 'No', MUCD_DOMAIN ) ); | ||
|
||
/** | ||
* Admin Page Duplicate MESSAGES | ||
*/ | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_DASHBOARD', __( 'Dashboard', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_VISIT', __( 'Visit', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_VIEW_LOG', __( 'View log', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_MISSING_FIELDS', __( 'Missing fields', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_TITLE_ERROR_REQUIRE', __( 'Missing or invalid title', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_DOMAIN_ERROR_RESERVED_WORDS', __( 'The following words are reserved for use by WordPress functions and cannot be used as blog names : <code>%s</code>', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_DOMAIN_ERROR_REQUIRE', __( 'Missing or invalid site address', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_EMAIL_MISSING', __( 'Missing admin email address', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_EMAIL_ERROR_FORMAT', __( 'Invalid admin email address', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_VIEW_LOG_PATH_EMPTY', __( 'Missing or invalid log directory path', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_NOTICE_CREATED', __( 'New site was created', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_ADMIN_ERROR_CREATE_USER', __( 'There was an error creating the user.', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_COPY_FILE_ERROR', __( 'Failed to copy files : check permissions on <strong>%s</strong>', MUCD_DOMAIN ) ); | ||
|
||
/** | ||
* Admin Page Duplicate FORM | ||
*/ | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_TITLE', __( 'Duplicate Site', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_FIELD_SOURCE', __( 'Original site to copy', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_FIELD_ADDRESS', __( 'New Site - Address', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_FIELD_ADDRESS_INFO', __( 'Only lowercase letters (a-z) and numbers are allowed.', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_FIELD_TITLE', __( 'New Site - Title', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_FIELD_EMAIL', __( 'New Site - Admin Email', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_FIELD_EMAIL_INFO_1', __( 'A new user will be created if the above email address is not in the database.', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_FIELD_EMAIL_INFO_2', __( 'The username and password will be mailed to this email address.', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_ADVANCED_SHOW', __( 'Show advanced options', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_ADVANCED_HIDE', __( 'Hide advanced options', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_FILES', __( 'Files', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_FILES_TEXT_1', __( 'Duplicate files from duplicated site upload directory', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_USERS', __( 'Users and roles', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_USERS_TEXT_1', __( 'Keep users and roles from duplicated site', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_LOG', __( 'Log', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_LOG_TEXT_1', __( 'Generate log file', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_LOG_TEXT_2', __( 'Log directory', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_BUTTON_COPY', __( 'Duplicate', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_PAGE_DUPLICATE_TOOLTIP', __( 'Edit duplicable sites list', MUCD_DOMAIN ) ); | ||
|
||
/** | ||
* Settings | ||
*/ | ||
define( 'MUCD_NETWORK_SETTINGS_DUPLICABLE_WEBSITES', __( 'Dublicable websites', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_SETTINGS_DUPLICABLE_ALL', __( 'Allow duplication of all sites of the network', MUCD_DOMAIN ) ); | ||
define( 'MUCD_NETWORK_SETTINGS_DUPLICABLE_SELECTED', __( 'Allow duplication of following sites only :', MUCD_DOMAIN ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
<?php | ||
/** | ||
* Option management for the plugin | ||
*/ | ||
if( !class_exists( 'MUCD_Option' ) ) { | ||
|
||
class MUCD_Option { | ||
|
||
/** | ||
* Init 'mucd_duplicable' options | ||
* @param string $blogs_value the value for blogs options | ||
* @param string $network_value the value for site option | ||
* @since 0.2.0 | ||
*/ | ||
public static function init_duplicable_option($blogs_value = "no", $network_value = "all") { | ||
$network_blogs = wp_get_sites(array('limit' => MUCD_MAX_NUMBER_OF_SITE)); | ||
foreach( $network_blogs as $blog ){ | ||
$blog_id = $blog['blog_id']; | ||
add_blog_option( $blog_id, 'mucd_duplicable', $blogs_value); | ||
} | ||
add_site_option( 'mucd_duplicables', $network_value ); | ||
} | ||
|
||
/** | ||
* Delete 'mucd_duplicable' option for all sites | ||
* @since 0.2.0 | ||
*/ | ||
public static function delete_duplicable_option() { | ||
$network_blogs = wp_get_sites(array('limit' => MUCD_MAX_NUMBER_OF_SITE)); | ||
foreach( $network_blogs as $blog ){ | ||
$blog_id = $blog['blog_id']; | ||
delete_blog_option( $blog_id, 'mucd_duplicable'); | ||
} | ||
delete_site_option( 'mucd_duplicables'); | ||
} | ||
|
||
/** | ||
* Set 'mucd_duplicable' option to "yes" for the list of blogs, other to "no" | ||
* @since 0.2.0 | ||
* @param array $blogs list of blogs we want the option set to "yes" | ||
*/ | ||
public static function set_duplicable_option($blogs) { | ||
$network_blogs = wp_get_sites(array('limit' => MUCD_MAX_NUMBER_OF_SITE)); | ||
foreach( $network_blogs as $blog ){ | ||
if(in_array($blog['blog_id'], $blogs)) { | ||
update_blog_option( $blog['blog_id'], 'mucd_duplicable', "yes"); | ||
} | ||
else { | ||
update_blog_option($blog['blog_id'], 'mucd_duplicable', "no"); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Add plugin default options | ||
* @since 1.3.0 | ||
*/ | ||
public static function init_options() { | ||
add_site_option('mucd_copy_files', 'yes'); | ||
add_site_option('mucd_keep_users', 'yes'); | ||
add_site_option('mucd_log', 'no'); | ||
add_site_option('mucd_log_dir', MUCD_COMPLETE_PATH . '/logs/'); | ||
MUCD_Option::init_duplicable_option(); | ||
} | ||
|
||
/** | ||
* Removes plugin options | ||
* @since 1.3.0 | ||
*/ | ||
public static function delete_options() { | ||
delete_site_option('mucd_copy_files'); | ||
delete_site_option('mucd_keep_users'); | ||
delete_site_option('mucd_log'); | ||
delete_site_option('mucd_log_dir'); | ||
MUCD_Option::delete_duplicable_option(); | ||
} | ||
|
||
/** | ||
* Get log directory option | ||
* @since 0.2.0 | ||
* @return string the path | ||
*/ | ||
public static function get_option_log_directory() { | ||
return get_site_option('mucd_log_dir', MUCD_COMPLETE_PATH . '/logs/'); | ||
} | ||
|
||
/** | ||
* Get directories to exclude from file copy when duplicated site is primary site | ||
* @since 0.2.0 | ||
* @return array of string | ||
*/ | ||
public static function get_primary_dir_exclude() { | ||
return array( | ||
'sites', | ||
); | ||
} | ||
|
||
/** | ||
* Get default options that should be preserved in the new blog. | ||
* @since 0.2.0 | ||
* @return array of string | ||
*/ | ||
public static function get_default_saved_option() { | ||
return array( | ||
'siteurl'=>'', | ||
'home'=>'', | ||
'upload_path'=>'', | ||
'fileupload_url'=>'', | ||
'upload_url_path'=>'', | ||
'admin_email'=>'', | ||
'blogname'=>'' | ||
); | ||
} | ||
|
||
/** | ||
* Get filtered options that should be preserved in the new blog. | ||
* @since 0.2.0 | ||
* @return array of string (filtered) | ||
*/ | ||
public static function get_saved_option() { | ||
return apply_filters('mucd_copy_blog_data_saved_options', MUCD_Option::get_default_saved_option()); | ||
} | ||
|
||
/** | ||
* Get default fields to scan for an update after data copy | ||
* @since 0.2.0 | ||
* @return array '%table_name' => array('%field_name_1','%field_name_2','%field_name_3', ...) | ||
*/ | ||
public static function get_default_fields_to_update() { | ||
return array ( | ||
'commentmeta' => array(), | ||
'comments' => array(), | ||
'links' => array('link_url', 'link_image'), | ||
'options' => array('option_name', 'option_value'), | ||
'postmeta' => array('meta_value'), | ||
'posts' => array('post_content', 'guid'), | ||
'terms' => array(), | ||
'term_relationships' => array(), | ||
'term_taxonomy' => array(), | ||
); | ||
} | ||
|
||
/** | ||
* Get filtered fields to scan for an update after data copy | ||
* @since 0.2.0 | ||
* @return array of string (filtered) | ||
*/ | ||
public static function get_fields_to_update() { | ||
return apply_filters('mucd_default_fields_to_update', MUCD_Option::get_default_fields_to_update()); | ||
} | ||
|
||
/** | ||
* Get default tables to duplicate when duplicated site is primary site | ||
* @since 0.2.0 | ||
* @return array of string | ||
*/ | ||
public static function get_default_primary_tables_to_copy() { | ||
return array ( | ||
'commentmeta', | ||
'comments', | ||
'links', | ||
'options', | ||
'postmeta', | ||
'posts', | ||
'terms', | ||
'term_relationships', | ||
'term_taxonomy', | ||
); | ||
} | ||
|
||
/** | ||
* Get filtered tables to duplicate when duplicated site is primary site | ||
* @since 0.2.0 | ||
* @return array of string (filtered) | ||
*/ | ||
public static function get_primary_tables_to_copy() { | ||
return apply_filters('mucd_default_primary_tables_to_copy', MUCD_Option::get_default_primary_tables_to_copy()); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
jQuery(document).ready(function() { | ||
|
||
// Logbox displaying | ||
jQuery('#log-box').change(function() { | ||
if(jQuery(this).is(":checked")) { | ||
jQuery('#log-path').prop('disabled', false); | ||
} | ||
else { | ||
jQuery('#log-path').prop('disabled', true); | ||
} | ||
}).change(); | ||
|
||
// Advanced Options fields displaying | ||
jQuery('#show-advanced-options, #hide-advanced-options').click(function() { | ||
mucd_toggle_advanced_options (jQuery(this).attr('id')); | ||
}); | ||
// If display when user Post, Form reload with Advanced Options field displayed | ||
if(jQuery('#status-advanced-options').val() == 'show-advanced-options'){ | ||
mucd_toggle_advanced_options ( jQuery('#status-advanced-options').val()); | ||
} | ||
|
||
// Function to controle toggle on Advanced Options fields | ||
function mucd_toggle_advanced_options (value){ | ||
jQuery('#advanced-options').toggle(); | ||
jQuery('#hide-advanced-options, #show-advanced-options').toggle(); | ||
jQuery(this).hide(); | ||
jQuery('#status-advanced-options').val(value); | ||
} | ||
|
||
}); |
Oops, something went wrong.