Changeset 3157334
- Timestamp:
- 09/25/2024 08:38:34 AM (18 months ago)
- Location:
- embed-sharepoint-onedrive-documents
- Files:
-
- 128 added
- 28 deleted
- 4 edited
-
tags/2.3.0 (added)
-
tags/2.3.0/API (added)
-
tags/2.3.0/API/class-authorization.php (added)
-
tags/2.3.0/API/class-azure.php (added)
-
tags/2.3.0/API/class-customermosps.php (added)
-
tags/2.3.0/Controller (added)
-
tags/2.3.0/Controller/class-accountsetuphandler.php (added)
-
tags/2.3.0/Controller/class-admincontroller.php (added)
-
tags/2.3.0/Controller/class-appconfig.php (added)
-
tags/2.3.0/Observer (added)
-
tags/2.3.0/Observer/class-adminobserver.php (added)
-
tags/2.3.0/Observer/class-appconfigobserver.php (added)
-
tags/2.3.0/Observer/class-documentobserver.php (added)
-
tags/2.3.0/Observer/class-shortcodesharepoint.php (added)
-
tags/2.3.0/View (added)
-
tags/2.3.0/View/class-accountsetup.php (added)
-
tags/2.3.0/View/class-adminview.php (added)
-
tags/2.3.0/View/class-advancedsettings.php (added)
-
tags/2.3.0/View/class-appconfig.php (added)
-
tags/2.3.0/View/class-demorequest.php (added)
-
tags/2.3.0/View/class-documentssync.php (added)
-
tags/2.3.0/View/class-feedbackform.php (added)
-
tags/2.3.0/View/class-shortcode.php (added)
-
tags/2.3.0/View/class-supportform.php (added)
-
tags/2.3.0/Wrappers (added)
-
tags/2.3.0/Wrappers/class-pluginconstants.php (added)
-
tags/2.3.0/Wrappers/class-wpwrapper.php (added)
-
tags/2.3.0/class-wp-namespace-autoloader.php (added)
-
tags/2.3.0/embed-sharepoint-onedrive-documents.php (added)
-
tags/2.3.0/images (added)
-
tags/2.3.0/images/18_step.png (added)
-
tags/2.3.0/images/19_step.png (added)
-
tags/2.3.0/images/61456.png (added)
-
tags/2.3.0/images/Chasing_arrows.gif (added)
-
tags/2.3.0/images/add.svg (added)
-
tags/2.3.0/images/angry.png (added)
-
tags/2.3.0/images/auto_connection_step1.png (added)
-
tags/2.3.0/images/auto_connection_step2.png (added)
-
tags/2.3.0/images/auto_connection_step3.png (added)
-
tags/2.3.0/images/checked.png (added)
-
tags/2.3.0/images/copy.png (added)
-
tags/2.3.0/images/demo.png (added)
-
tags/2.3.0/images/doc_preview_step.png (added)
-
tags/2.3.0/images/document.png (added)
-
tags/2.3.0/images/down-arrow.svg (added)
-
tags/2.3.0/images/download.svg (added)
-
tags/2.3.0/images/empty_folder_drop.svg (added)
-
tags/2.3.0/images/error.svg (added)
-
tags/2.3.0/images/file.png (added)
-
tags/2.3.0/images/flags16.png (added)
-
tags/2.3.0/images/folder.png (added)
-
tags/2.3.0/images/folder.svg (added)
-
tags/2.3.0/images/folder_main.svg (added)
-
tags/2.3.0/images/folder_mainn.svg (added)
-
tags/2.3.0/images/graph.png (added)
-
tags/2.3.0/images/gutenberg.png (added)
-
tags/2.3.0/images/happy.png (added)
-
tags/2.3.0/images/info.png (added)
-
tags/2.3.0/images/loader.gif (added)
-
tags/2.3.0/images/lock.svg (added)
-
tags/2.3.0/images/login.png (added)
-
tags/2.3.0/images/menu_logo.png (added)
-
tags/2.3.0/images/microsoft-sharepoint.svg (added)
-
tags/2.3.0/images/miniorange.png (added)
-
tags/2.3.0/images/miniorange_logo.png (added)
-
tags/2.3.0/images/msexcel_file.png (added)
-
tags/2.3.0/images/msword_file.png (added)
-
tags/2.3.0/images/normal.png (added)
-
tags/2.3.0/images/onedrive.png (added)
-
tags/2.3.0/images/open-folder.png (added)
-
tags/2.3.0/images/pdf_file.png (added)
-
tags/2.3.0/images/plugin_test_connection.png (added)
-
tags/2.3.0/images/profits.webp (added)
-
tags/2.3.0/images/redirect.svg (added)
-
tags/2.3.0/images/refresh.svg (added)
-
tags/2.3.0/images/sad.png (added)
-
tags/2.3.0/images/scroll-text.svg (added)
-
tags/2.3.0/images/settings.png (added)
-
tags/2.3.0/images/setupguide.svg (added)
-
tags/2.3.0/images/short.png (added)
-
tags/2.3.0/images/shortcode.png (added)
-
tags/2.3.0/images/smile.png (added)
-
tags/2.3.0/images/support-header2.jpg (added)
-
tags/2.3.0/images/tick.svg (added)
-
tags/2.3.0/images/userr.png (added)
-
tags/2.3.0/images/users.svg (added)
-
tags/2.3.0/includes (added)
-
tags/2.3.0/includes/css (added)
-
tags/2.3.0/includes/css/doc-embed.css (added)
-
tags/2.3.0/includes/css/jquery-ui.css (added)
-
tags/2.3.0/includes/css/license.css (added)
-
tags/2.3.0/includes/css/media.css (added)
-
tags/2.3.0/includes/css/mo_sps_settings.css (added)
-
tags/2.3.0/includes/css/phone.css (added)
-
tags/2.3.0/includes/css/select2.min.css (added)
-
tags/2.3.0/includes/js (added)
-
tags/2.3.0/includes/js/ajax.js (added)
-
tags/2.3.0/includes/js/appConfig.js (added)
-
tags/2.3.0/includes/js/gutenburg-block.js (added)
-
tags/2.3.0/includes/js/media.js (added)
-
tags/2.3.0/includes/js/phone.js (added)
-
tags/2.3.0/includes/js/select2.min.js (added)
-
tags/2.3.0/includes/js/settings.js (added)
-
tags/2.3.0/includes/js/settings.min.js (added)
-
tags/2.3.0/readme.txt (added)
-
tags/2.3.0/uninstall.php (added)
-
trunk/API/Authorization.php (deleted)
-
trunk/API/Azure.php (deleted)
-
trunk/API/CustomerMOSPS.php (deleted)
-
trunk/API/class-authorization.php (added)
-
trunk/API/class-azure.php (added)
-
trunk/API/class-customermosps.php (added)
-
trunk/Controller/accountSetupHandler.php (deleted)
-
trunk/Controller/adminController.php (deleted)
-
trunk/Controller/appConfig.php (deleted)
-
trunk/Controller/class-accountsetuphandler.php (added)
-
trunk/Controller/class-admincontroller.php (added)
-
trunk/Controller/class-appconfig.php (added)
-
trunk/Observer/adminObserver.php (deleted)
-
trunk/Observer/appConfigObserver.php (deleted)
-
trunk/Observer/class-adminobserver.php (added)
-
trunk/Observer/class-appconfigobserver.php (added)
-
trunk/Observer/class-documentobserver.php (added)
-
trunk/Observer/class-shortcodesharepoint.php (added)
-
trunk/Observer/documentObserver.php (deleted)
-
trunk/Observer/shortcodeSharepoint.php (deleted)
-
trunk/View/Shortcode.php (deleted)
-
trunk/View/accountSetup.php (deleted)
-
trunk/View/adminView.php (deleted)
-
trunk/View/advancedSettings.php (deleted)
-
trunk/View/appConfig.php (deleted)
-
trunk/View/class-accountsetup.php (added)
-
trunk/View/class-adminview.php (added)
-
trunk/View/class-advancedsettings.php (added)
-
trunk/View/class-appconfig.php (added)
-
trunk/View/class-demorequest.php (added)
-
trunk/View/class-documentssync.php (added)
-
trunk/View/class-feedbackform.php (added)
-
trunk/View/class-shortcode.php (added)
-
trunk/View/class-supportform.php (added)
-
trunk/View/demoRequest.php (deleted)
-
trunk/View/documentsSync.php (deleted)
-
trunk/View/feedbackForm.php (deleted)
-
trunk/View/setupGuide.php (deleted)
-
trunk/View/supportForm.php (deleted)
-
trunk/View/syncUser.php (deleted)
-
trunk/Wrappers/class-pluginconstants.php (added)
-
trunk/Wrappers/class-wpwrapper.php (added)
-
trunk/Wrappers/pluginConstants.php (deleted)
-
trunk/Wrappers/sharepointWrapper.php (deleted)
-
trunk/Wrappers/uninstall.php (deleted)
-
trunk/Wrappers/wpWrapper.php (deleted)
-
trunk/class-wp-namespace-autoloader.php (added)
-
trunk/composer.json (deleted)
-
trunk/composer.lock (deleted)
-
trunk/embed-sharepoint-onedrive-documents.php (modified) (1 diff)
-
trunk/includes/js/ajax.js (modified) (1 diff)
-
trunk/readme.txt (modified) (7 diffs)
-
trunk/uninstall.php (modified) (1 diff)
-
trunk/vendor (deleted)
Legend:
- Unmodified
- Added
- Removed
-
embed-sharepoint-onedrive-documents/trunk/embed-sharepoint-onedrive-documents.php
r3102687 r3157334 1 1 <?php 2 3 2 /* 4 3 Plugin Name: Embed SharePoint OneDrive Documents 5 4 Plugin URI: https://plugins.miniorange.com/ 6 Description: This plugin allows you to sync and embed SharePoint documents, folders, and files in WordPress. You can download and preview SharePoint files directly from WordPress. 7 Version: 2. 2.95 Description: This plugin allows you to sync and embed SharePoint documents, folders, and files in WordPress. You can download and preview SharePoint files directly from WordPress. 6 Version: 2.3.0 8 7 Author: miniOrange 9 License: GPLv2 or later8 License: MIT 10 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 10 */ 12 11 13 12 namespace MoSharePointObjectSync; 14 require_once __DIR__ . '/vendor/autoload.php'; 15 16 use MoSharePointObjectSync\View\adminView; 17 use MoSharePointObjectSync\Controller\adminController; 18 use MoSharePointObjectSync\Observer\adminObserver; 19 use MoSharePointObjectSync\Observer\appConfigObserver; 20 use MoSharePointObjectSync\Observer\documentObserver; 13 14 require_once __DIR__ . '/class-wp-namespace-autoloader.php'; 15 16 use MoSharePointObjectSync\View\AdminView; 17 use MoSharePointObjectSync\Controller\AdminController; 18 use MoSharePointObjectSync\Observer\AdminObserver; 19 use MoSharePointObjectSync\Observer\AppConfigObserver; 20 use MoSharePointObjectSync\Observer\DocumentObserver; 21 21 use MoSharePointObjectSync\Observer\shortcodeSharepoint; 22 22 23 use MoSharePointObjectSync\View\feedbackForm; 24 use MoSharePointObjectSync\Wrappers\pluginConstants; 25 use MoSharePointObjectSync\Wrappers\wpWrapper; 26 27 define('MO_SPS_PLUGIN_FILE',__FILE__); 28 define('MO_SPS_PLUGIN_DIR',__DIR__.DIRECTORY_SEPARATOR); 29 define('MO_SPS_PLUGIN_URL', plugins_url('', __FILE__)); 30 define('PLUGIN_VERSION', '2.2.9' ); 31 32 class MOsps{ 33 34 private static $instance; 35 public static $version = PLUGIN_VERSION; 36 37 private function __construct() { 23 use MoSharePointObjectSync\View\FeedbackForm; 24 use MoSharePointObjectSync\Wrappers\PluginConstants; 25 use MoSharePointObjectSync\Wrappers\WpWrapper; 26 27 define( 'MO_SPS_PLUGIN_URL', plugins_url( '', __FILE__ ) ); 28 define( 'MO_SPS_PLUGIN_VERSION', '2.2.9' ); 29 define( 'MO_SPS_PLUGIN_FILE', __FILE__ ); 30 /** 31 * The main class ofEmbed SharePoint OneDrive Documents plugin. 32 */ 33 class MOsps { 34 /** 35 * Holds the singleton instance of the MOsps. 36 * 37 * @var MOsps 38 */ 39 private static $instance; 40 /** 41 * The current version of the plugin. 42 * 43 * @var string The version number of the SharePoint plugin, defined as a constant. 44 */ 45 public static $version = MO_SPS_PLUGIN_VERSION; 46 /** 47 * Constructor method for the class. 48 * 49 * This private constructor initializes the class by calling the `mo_sps_load_hooks` method, 50 * which sets up the necessary hooks for the plugin's functionality. 51 * 52 * The constructor is private to enforce the singleton pattern, ensuring that only one instance 53 * of the class can be created. 54 */ 55 private function __construct() { 38 56 $this->mo_sps_load_hooks(); 39 57 } 40 41 public static function mo_sps_load_instance(){ 42 if(!isset(self::$instance)){ 43 self::$instance = new self(); 44 } 45 return self::$instance; 46 } 47 48 private function mo_sps_load_hooks(){ 49 add_action('admin_menu',[$this,'mo_sps_admin_menu']); 50 add_action( 'admin_enqueue_scripts', [$this, 'mo_sps_enqueue_admin_styles' ] ); 51 add_action( 'admin_enqueue_scripts', array( $this, 'mo_sps_settings_script' ) ); 52 add_action('admin_init',[adminController::getController(),'mo_sps_admin_controller']); 53 add_action( 'admin_footer', [feedbackForm::getView() , 'mo_sps_display_feedback_form'] ); 54 add_action('init',[adminObserver::getObserver(),'mo_sps_admin_observer']); 55 register_activation_hook(__FILE__,array($this,'mo_sps_plugin_activate')); 56 add_shortcode( 'MO_SPS_SHAREPOINT', [shortcodeSharepoint::getObserver(),'mo_sps_shortcode_document_observer'] ); 57 add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array($this,'settings_link')); 58 add_action( 'init',[$this,'mo_sps_gutenburg']); 59 add_action( "wp_ajax_mo_doc_embed", [documentObserver::getObserver(), 'mo_sps_doc_embed']); 60 add_action('wp_ajax_mo_sps_app_configuration',[appConfigObserver::getObserver(),'mo_sps_app_configuration_api_handler']); 61 add_action( 'wp_ajax_mo_sps_get_file_web_url', array( documentObserver::getObserver(), 'mo_sps_get_file_web_url' ) ); 62 register_uninstall_hook(__FILE__, 'mo_sps_uninstall'); 63 add_action('admin_init', [$this,'mo_sps_plugin_check_migration']); 64 add_action('admin_init', [$this,'mo_sps_plugin_handle_migration_action']); 65 } 66 67 function mo_sps_plugin_check_migration() { 68 if ( get_option('mo_sps_application_config') && !get_option('mo_sps_plugin_migration_completed')) { 69 add_action('admin_notices', [$this,'mo_sps_plugin_migration_notice']); 70 } else if(! get_option('mo_sps_application_config')) { 71 update_option('mo_sps_plugin_migration_completed', true); 72 } 73 } 74 75 function mo_sps_plugin_migration_notice() { 76 $tab = isset($_GET['tab']) ? $_GET['tab'] : 'app_config'; 77 if((isset($_GET['page']) && $_GET['page'] == 'mo_sps') && $tab == 'app_config') { 78 ?> 79 <div class="notice notice-info"> 80 <p><?php _e('It seems you already have some configurations set up from the previous version of the plugin. Click on the button below to migrate your configurations.'); ?></p> 81 <form method="post" action=""> 82 <input type="hidden" name="mo_sps_plugin_migration_action" value="migrate_configurations"> 83 <?php submit_button(__('Migrate Configurations'), 'primary', 'mo_sps_plugin_migrate_button'); ?> 84 </form> 85 </div> 86 <?php 87 } 88 } 89 90 function mo_sps_plugin_handle_migration_action() { 91 if (isset($_POST['mo_sps_plugin_migration_action']) && $_POST['mo_sps_plugin_migration_action'] === 'migrate_configurations' && !get_option('mo_sps_plugin_migration_completed')) { 92 update_option('mo_sps_test_connection_status', 'success'); 93 update_option('mo_sps_plugin_migration_completed', true); 94 ?> 95 <script type="text/javascript"> 96 window.onload = function() { 97 if (window.location.href.indexOf('page=mo_sps&tab=app_config') !== -1) { 98 location.reload(); 99 } 100 }; 101 </script> 102 <?php 103 } 104 } 105 106 public function mo_sps_load_media_library_scripts() 107 { 108 global $pagenow; 109 110 $mode = get_user_option('media_library_mode', get_current_user_id()) ? get_user_option('media_library_mode', get_current_user_id()) : 'grid'; 111 if ($mode === 'list' || $mode === 'grid') { 112 $this->mo_sps_load_assets(); 113 } 114 115 116 } 117 118 public function mo_sps_load_assets() 119 { 120 wp_enqueue_script('jquery'); 121 122 123 wp_enqueue_style( 124 'mo-sps-style', 125 plugins_url('/includes/css/media.css', __FILE__), 126 array(), 127 PLUGIN_VERSION 128 ); 129 130 wp_register_script( 131 'mo-sps-base', 132 plugins_url('/includes/js/media.js', __FILE__), 133 array('jquery'), 134 PLUGIN_VERSION 135 ); 136 137 $params = [ 138 'sharepoint_icon' => esc_url(MO_SPS_PLUGIN_URL.'/images/microsoft-sharepoint.svg'), 139 'admin_uri' => admin_url(), 140 ]; 141 wp_enqueue_script('mo-sps-base'); 142 wp_add_inline_script('mo-sps-base', 'var mo_sps='.json_encode($params).';', 'before' ); 143 144 145 } 146 147 public function mo_sps_plugin_activate(){ 148 wpWrapper::mo_sps_set_option("mo_sps_feedback_config",array()); 149 } 150 151 public function mo_sps_admin_menu(){ 152 $page = add_menu_page( 153 'SharePoint/OneDrive' .__('+ Sync'), 154 'SharePoint / OneDrive', 155 'administrator', 156 'mo_sps', 157 [adminView::getView(),'mo_sps_menu_display'], 158 plugin_dir_url( __FILE__ ) . 'images/menu_logo.png' 159 ); 160 } 161 162 function mo_sps_enqueue_admin_styles($page){ 163 164 global $pagenow; 165 166 if ($pagenow === 'upload.php') { 167 $this->mo_sps_load_media_library_scripts(); 168 } 169 170 if( $page != 'toplevel_page_mo_sps'){ 171 return; 172 } 173 174 $css_url = plugins_url('includes/css/mo_sps_settings.css',__FILE__); 175 $css_phone_url = plugins_url('includes/css/phone.css',__FILE__); 176 $css_jquery_ui_url = plugins_url('includes/css/jquery-ui.css',__FILE__); 177 $css_license_view_url = plugins_url('includes/css/license.css',__FILE__); 178 179 wp_enqueue_style('mo_sps_css',$css_url,array(),self::$version); 180 wp_enqueue_style('mo_sps_phone_css',$css_phone_url,array(),self::$version); 181 wp_enqueue_style('mo_sps_jquery_ui_css',$css_jquery_ui_url,array(),self::$version); 182 wp_enqueue_style('mo_sps_license_view_css',$css_license_view_url,array(),self::$version); 183 } 184 185 function mo_sps_enqueue_styles($page) { 186 global $pagenow; 187 188 if ($pagenow === 'upload.php') { 189 $this->mo_sps_load_media_library_scripts(); 190 } 191 192 if( $page != 'toplevel_page_mo_sps'){ 193 return; 194 } 195 196 $css_jquery_ui_url = plugins_url('includes/css/jquery-ui.css',__FILE__); 197 wp_enqueue_style('mo_sps_jquery_ui_css',$css_jquery_ui_url,array(),self::$version); 198 } 199 200 function mo_sps_settings_script($page){ 201 $phone_js_url = plugins_url('includes/js/phone.js',__FILE__); 202 $setting_js_url= plugins_url('includes/js/settings.js',__FILE__); 203 wp_enqueue_script('mo_sps_phone_js',$phone_js_url,array(),self::$version); 204 wp_enqueue_script('mo_settings_js',$setting_js_url,array(),self::$version); 205 } 206 207 function so_enqueue_scripts(){ 208 wp_register_script( 209 'ajaxHandle', 210 plugins_url('includes/js/ajax.js', __FILE__), 211 array(), 212 false, 213 true 214 ); 215 wp_enqueue_script( 'ajaxHandle' ); 216 wp_add_inline_script( 217 'ajaxHandle', 218 'var ajax_object='.json_encode(array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ).';', 'before' 219 ); 220 } 221 222 function settings_link( $links ) { 223 // Build and escape the URL. 224 $url = esc_url( add_query_arg( 225 'page', 226 'mo_sps', 227 get_admin_url() . 'admin.php' 228 ) ); 229 // Create the link. 230 $settings_link = "<a href='$url'>" . __( 'Settings' ) . '</a>'; 231 // Adds the link to the end of the array. 232 array_push( 233 $links, 234 $settings_link 235 ); 236 return $links; 237 } 238 function mo_sps_gutenburg() { 239 $src = plugins_url('includes/js/gutenburg-block.js',__FILE__); 240 241 wp_register_script('custom-cta-js', $src, array('wp-blocks','wp-editor'), self::$version); 242 243 244 if(isset($_GET['post'])) 245 { 246 $post_id = $_GET['post']; 247 $post_info = get_post( $post_id); 248 $post_content = ! empty($post_info->post_content) ? wp_strip_all_tags($post_info->post_content) : ''; 249 250 wp_add_inline_script('custom-cta-js','var post_content='.json_encode($post_content).';', 'before'); 251 252 253 } 254 255 register_block_type('sps/custom-cta',array( 256 'editor_script' => 'custom-cta-js', 257 258 )); 259 260 261 } 58 /** 59 * Get the singleton instance of the class. 60 * 61 * Ensures only one instance is created and returns it. 62 * 63 * @return self The class instance. 64 */ 65 public static function mo_sps_load_instance() { 66 if ( ! isset( self::$instance ) ) { 67 self::$instance = new self(); 68 } 69 return self::$instance; 70 } 71 /** 72 * Registers all necessary hooks and actions for the plugin. 73 * 74 * This method sets up WordPress actions, filters, shortcodes, and activation/uninstall hooks 75 * to ensure proper functionality of the plugin. 76 */ 77 private function mo_sps_load_hooks() { 78 add_action( 'admin_menu', array( $this, 'mo_sps_admin_menu' ) ); 79 add_action( 'admin_enqueue_scripts', array( $this, 'mo_sps_enqueue_admin_styles' ) ); 80 add_action( 'admin_enqueue_scripts', array( $this, 'mo_sps_settings_script' ) ); 81 add_action( 'admin_init', array( AdminController::get_controller(), 'mo_sps_admin_controller' ) ); 82 add_action( 'admin_footer', array( FeedbackForm::get_view(), 'mo_sps_display_feedback_form' ) ); 83 add_action( 'init', array( AdminObserver::get_observer(), 'mo_sps_admin_observer' ) ); 84 register_activation_hook( __FILE__, array( $this, 'mo_sps_plugin_activate' ) ); 85 add_shortcode( 'MO_SPS_SHAREPOINT', array( ShortcodeSharepoint::get_observer(), 'mo_sps_shortcode_document_observer' ) ); 86 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'settings_link' ) ); 87 add_filter( 'allowed_redirect_hosts', array( $this, 'extend_allowed_redirect_hosts' ) ); 88 add_action( 'init', array( $this, 'mo_sps_gutenburg' ) ); 89 add_action( 'wp_ajax_mo_doc_embed', array( DocumentObserver::get_observer(), 'mo_sps_doc_embed' ) ); 90 add_action( 'wp_ajax_mo_sps_app_configuration', array( AppConfigObserver::get_observer(), 'mo_sps_app_configuration_api_handler' ) ); 91 add_action( 'wp_ajax_mo_sps_get_file_web_url', array( DocumentObserver::get_observer(), 'mo_sps_get_file_web_url' ) ); 92 register_uninstall_hook( __FILE__, 'mo_sps_uninstall' ); 93 add_action( 'admin_init', array( $this, 'mo_sps_plugin_check_migration' ) ); 94 add_action( 'admin_init', array( $this, 'mo_sps_plugin_handle_migration_action' ) ); 95 } 96 /** 97 * Checks if plugin migration is required and triggers the appropriate actions. 98 */ 99 public function mo_sps_plugin_check_migration() { 100 if ( get_option( 'mo_sps_application_config' ) && ! get_option( 'mo_sps_plugin_migration_completed' ) ) { 101 add_action( 'admin_notices', array( $this, 'mo_sps_plugin_migration_notice' ) ); 102 } elseif ( ! get_option( 'mo_sps_application_config' ) ) { 103 update_option( 'mo_sps_plugin_migration_completed', true ); 104 } 105 } 106 /** 107 * This function adds 'login.microsoftonline.com' to the list of allowed 108 * redirect hosts, enabling safe redirection to external domains when using 109 * wp_safe_redirect. 110 * 111 * @param array $hosts An array of currently allowed hosts for redirection. 112 */ 113 public function extend_allowed_redirect_hosts( $hosts ) { 114 $hosts[] = 'login.microsoftonline.com'; 115 $hosts[] = 'login.live.com'; 116 return $hosts; 117 } 118 /** 119 * Displays a migration notice in the admin area if configuration migration is needed. 120 */ 121 public function mo_sps_plugin_migration_notice() { 122 //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reading GET parameter from the URL for checking tab name, doesn't require nonce verification. 123 $tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : 'app_config'; 124 //PHPCS:ignore -- WordPress.Security.NonceVerification.Recommended -- GET parameter for checking the current page name from the URL doesn't require nonce verification. 125 if ( ( isset( $_GET['page'] ) && 'mo_sps' === $_GET['page'] ) && 'app_config' === $tab ) { 126 ?> 127 <div class="notice notice-info"> 128 <p><?php echo 'It seems you already have some configurations set up from the previous version of the plugin. Click on the button below to migrate your configurations.'; ?></p> 129 <form method="post" action=""> 130 <?php wp_nonce_field( 'mo_sps_migration_action', 'mo_sps_nonce_field' ); ?> 131 <input type="hidden" name="mo_sps_plugin_migration_action" value="migrate_configurations"> 132 <?php submit_button( __( 'Migrate Configurations' ), 'primary', 'mo_sps_plugin_migrate_button' ); ?> 133 </form> 134 </div> 135 <?php 136 } 137 } 138 /** 139 * Handles the migration action when triggered, updates options, and reloads the page. 140 */ 141 public function mo_sps_plugin_handle_migration_action() { 142 if ( ! isset( $_POST['mo_sps_nonce_field'] ) || ! check_admin_referer( 'mo_sps_migration_action', 'mo_sps_nonce_field' ) ) { 143 return; 144 } 145 if ( isset( $_POST['mo_sps_plugin_migration_action'] ) && 'migrate_configurations' === $_POST['mo_sps_plugin_migration_action'] && ! get_option( 'mo_sps_plugin_migration_completed' ) ) { 146 update_option( 'mo_sps_test_connection_status', 'success' ); 147 update_option( 'mo_sps_plugin_migration_completed', true ); 148 ?> 149 <script type="text/javascript"> 150 window.onload = function() { 151 if (window.location.href.indexOf('page=mo_sps&tab=app_config') !== -1) { 152 location.reload(); 153 } 154 }; 155 </script> 156 <?php 157 } 158 } 159 /** 160 * Loads media library scripts based on the user's preferred mode (list or grid). 161 */ 162 public function mo_sps_load_media_library_scripts() { 163 global $pagenow; 164 165 $mode = get_user_option( 'media_library_mode', get_current_user_id() ) ? get_user_option( 'media_library_mode', get_current_user_id() ) : 'grid'; 166 if ( 'list' === $mode || 'grid' === $mode ) { 167 $this->mo_sps_load_assets(); 168 } 169 170 } 171 /** 172 * Enqueues and registers JavaScript and CSS assets for the plugin. 173 */ 174 public function mo_sps_load_assets() { 175 wp_enqueue_script( 'jquery' ); 176 177 wp_enqueue_style( 178 'mo-sps-style', 179 plugins_url( '/includes/css/media.css', __FILE__ ), 180 array(), 181 MO_SPS_PLUGIN_VERSION 182 ); 183 184 wp_register_script( 185 'mo-sps-base', 186 plugins_url( '/includes/js/media.js', __FILE__ ), 187 array( 'jquery' ), 188 MO_SPS_PLUGIN_VERSION, 189 false 190 ); 191 192 $params = array( 193 'sharepoint_icon' => esc_url( MO_SPS_PLUGIN_URL . '/images/microsoft-sharepoint.svg' ), 194 'admin_uri' => admin_url(), 195 ); 196 wp_enqueue_script( 'mo-sps-base' ); 197 wp_add_inline_script( 'mo-sps-base', 'var mo_sps=' . wp_json_encode( $params ) . ';', 'before' ); 198 199 } 200 /** 201 * Initializes plugin options upon activation. 202 */ 203 public function mo_sps_plugin_activate() { 204 WpWrapper::mo_sps_set_option( 'mo_sps_feedback_config', array() ); 205 } 206 /** 207 * Adds the SharePoint/OneDrive admin menu to the WordPress dashboard. 208 */ 209 public function mo_sps_admin_menu() { 210 $page = add_menu_page( 211 'SharePoint/OneDrive' . __( '+ Sync' ), 212 'SharePoint / OneDrive', 213 'administrator', 214 'mo_sps', 215 array( AdminView::get_view(), 'mo_sps_menu_display' ), 216 plugin_dir_url( __FILE__ ) . 'images/menu_logo.png' 217 ); 218 } 219 /** 220 * Enqueues admin styles for the plugin settings page and media library. 221 * 222 * @param string $page The current admin page slug. 223 */ 224 public function mo_sps_enqueue_admin_styles( $page ) { 225 226 global $pagenow; 227 228 if ( 'upload.php' === $pagenow ) { 229 $this->mo_sps_load_media_library_scripts(); 230 } 231 232 if ( 'toplevel_page_mo_sps' !== $page ) { 233 return; 234 } 235 236 $css_url = plugins_url( 'includes/css/mo_sps_settings.css', __FILE__ ); 237 $css_phone_url = plugins_url( 'includes/css/phone.css', __FILE__ ); 238 $css_jquery_ui_url = plugins_url( 'includes/css/jquery-ui.css', __FILE__ ); 239 $css_license_view_url = plugins_url( 'includes/css/license.css', __FILE__ ); 240 241 wp_enqueue_style( 'mo_sps_css', $css_url, array(), self::$version ); 242 wp_enqueue_style( 'mo_sps_phone_css', $css_phone_url, array(), self::$version ); 243 wp_enqueue_style( 'mo_sps_jquery_ui_css', $css_jquery_ui_url, array(), self::$version ); 244 wp_enqueue_style( 'mo_sps_license_view_css', $css_license_view_url, array(), self::$version ); 245 } 246 /** 247 * Enqueues styles for the plugin settings page and media library. 248 * 249 * @param string $page The current admin page slug. 250 */ 251 public function mo_sps_enqueue_styles( $page ) { 252 global $pagenow; 253 254 if ( 'upload.php' === $pagenow ) { 255 $this->mo_sps_load_media_library_scripts(); 256 } 257 258 if ( 'toplevel_page_mo_sps' !== $page ) { 259 return; 260 } 261 262 $css_jquery_ui_url = plugins_url( 'includes/css/jquery-ui.css', __FILE__ ); 263 wp_enqueue_style( 'mo_sps_jquery_ui_css', $css_jquery_ui_url, array(), self::$version ); 264 } 265 /** 266 * Enqueues JavaScript files for the plugin settings page. 267 * 268 * @param string $page The current admin page slug. 269 */ 270 public function mo_sps_settings_script( $page ) { 271 $phone_js_url = plugins_url( 'includes/js/phone.js', __FILE__ ); 272 $setting_js_url = plugins_url( 'includes/js/settings.js', __FILE__ ); 273 wp_enqueue_script( 'mo_sps_phone_js', $phone_js_url, array(), self::$version, false ); 274 wp_enqueue_script( 'mo_settings_js', $setting_js_url, array(), self::$version, false ); 275 } 276 /** 277 * Registers and enqueues the AJAX handling script and adds inline script for AJAX URL. 278 */ 279 public function so_enqueue_scripts() { 280 wp_register_script( 'ajaxHandle', plugins_url( 'includes/js/ajax.js', __FILE__ ), array(), MO_SPS_PLUGIN_VERSION, true ); 281 wp_enqueue_script( 'ajaxHandle' ); 282 wp_add_inline_script( 283 'ajaxHandle', 284 'var ajax_object=' . wp_json_encode( array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ) . ';', 285 'before' 286 ); 287 } 288 /** 289 * Adds a "Settings" link to the plugin action links. 290 * 291 * @param array $links Array of existing action links. 292 * @return array Modified array of action links with the "Settings" link appended. 293 */ 294 public function settings_link( $links ) { 295 // Build and escape the URL. 296 $url = esc_url( 297 add_query_arg( 298 'page', 299 'mo_sps', 300 get_admin_url() . 'admin.php' 301 ) 302 ); 303 // Create the link. 304 $settings_link = "<a href='$url'>" . __( 'Settings' ) . '</a>'; 305 // Adds the link to the end of the array. 306 array_push( 307 $links, 308 $settings_link 309 ); 310 return $links; 311 } 312 /** 313 * Registers a custom Gutenberg block and enqueues its JavaScript. 314 * 315 * Registers the JavaScript for the custom Gutenberg block and adds the post content as inline script if a post ID is provided. 316 */ 317 public function mo_sps_gutenburg() { 318 $src = plugins_url( 'includes/js/gutenburg-block.js', __FILE__ ); 319 320 wp_register_script( 'custom-cta-js', $src, array( 'wp-blocks', 'wp-editor' ), self::$version, false ); 321 if ( isset( $_GET['post'] ) ) { 322 $post_id = $_GET['post']; 323 $post_info = get_post( $post_id ); 324 $post_content = ! empty( $post_info->post_content ) ? wp_strip_all_tags( $post_info->post_content ) : ''; 325 326 wp_add_inline_script( 'custom-cta-js', 'var post_content=' . wp_json_encode( $post_content ) . ';', 'before' ); 327 328 } 329 330 register_block_type( 331 'sps/custom-cta', 332 array( 333 'editor_script' => 'custom-cta-js', 334 335 ) 336 ); 337 338 } 262 339 263 340 } -
embed-sharepoint-onedrive-documents/trunk/includes/js/ajax.js
r3091366 r3157334 343 343 var web_url = ele.getAttribute('web-url'); 344 344 if(config['searched_doc'] === true) { 345 var ajax_url = `${doc_sync_data.admin_ajax_url}?action=mo_sps_get_file_web_url& drive_id=${config['drive_id']}&file_id=${file_id}`;345 var ajax_url = `${doc_sync_data.admin_ajax_url}?action=mo_sps_get_file_web_url&nonce=${doc_sync_data.nonce}&drive_id=${config['drive_id']}&file_id=${file_id}`; 346 346 window.open(ajax_url, '_blank'); 347 347 } else { -
embed-sharepoint-onedrive-documents/trunk/readme.txt
r3134861 r3157334 6 6 Tested up to: 6.6 7 7 Requires PHP: 5.6 8 Stable tag: 2. 2.99 License: GPLv2 or later8 Stable tag: 2.3.0 9 License: MIT 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 11 … … 14 14 == Description == 15 15 16 WordPress Embed SharePoint OneDrive Documents plugin allows you to embed share OneDrive documents/files on your wordpress site. It also allows you to synchronize your sharepoint/OneDrive/Office365 user details / documents /files to the WordPress site. Your employees can create and view SharePoint OneDrive documents from the WordPress site, supporting seamless migrations and efficient data backup.16 WordPress Embed SharePoint OneDrive Documents plugin allows you to embed share OneDrive documents/files on your wordpress site. It also allows you to synchronize your sharepoint/OneDrive/Office365 user details / documents /files to the WordPress site. Your employees can create and view sharepoint OneDrive documents from the wordpress site. 17 17 18 18 [The Embed SharePoint OneDrive Document plugin](https://plugins.miniorange.com/microsoft-sharepoint-wordpress-integration/) also allows effective file management of SharePoint OneDrive folders / Files / Media in your wordpress site using integrations with 3rd party plugins like BuddyPress, WooCommerce, MemberPress, Paid Membership pro, etc. 19 19 20 You can also use sharepoint onedrive Integrator plugin to configure [Microsoft365/Office 365 apps](https://plugins.miniorange.com/wordpress-azure-ad-b2c-office-365-integrations/) like Power BI, SharePoint, Microsoft Teams, Dynamics CRM, Power Apps, Yammer, OneDrive, etc. with WordPress using Microsoft Graph APIs and User Sync for Azure AD/Azure B2C plugin for seamless Power BI integration, SharePoint integration, Dynamics CRM integration, and integration for other Office 365 apps. This supports migrations and ensures reliable backup from WordPress to SharePoint and vice-versa.20 You can also use sharepoint onedrive Integrator plugin to configure [Microsoft365/Office 365 apps](https://plugins.miniorange.com/wordpress-azure-ad-b2c-office-365-integrations/) like Power BI, SharePoint, Microsoft Teams, Dynamics CRM, Power Apps, Yammer, OneDrive, etc. with WordPress using Microsoft Graph APIs and User Sync for Azure AD/Azure B2C plugin for seamless Power BI integration, SharePoint integration, Dynamics CRM integration, and integration for other Office 365 apps. 21 21 22 22 == Features == … … 66 66 * Sync Office 365 Delve user profile attributes like About me, Skills, etc. to the WordPress site. 67 67 * Synchronize user details from WordPress to SharePoint 68 * Automatically create new users in SharePoint upon registration in WordPress, while also supporting the migration of existing users from WordPress to SharePoint and backup of user profiles.68 * Create new users in SharePoint once Registered in the WordPress 69 69 70 70 **Search SharePoint Files / Change View** … … 89 89 * Retrieve/Synchronize list of all sharepoint sites in the WordPress 90 90 * Retrieve/Synchronize metadata for single site in SharePoint to the WordPress 91 * Synchronize documents between WordPress and SharePoint libraries while ensuring easy migrations and data backup.91 * Synchronize SharePoint items to the WordPress site 92 92 * Create new SharePoint site from the WordPress 93 93 … … 95 95 96 96 * Sync SharePoint social feeds like news and articles into the WordPress posts. 97 * Useful for migrations and backup of social feed content.98 97 99 98 **Integration with OneDrive** 100 99 101 100 * Upload an existing file or attachement from WordPress to OneDrive 102 * Migrations of existing file,folders and attachement from WordPress to OneDrive. 103 * Create a new folder in OneDrive and add files from the Wordpress. 104 * Create new text file in OneDrive from the post created in the WordPress. 105 * Find file/Folder by name in the WordPress. Manage migrations and backup. 101 * Create a new folder in OneDrive and add files from the Wordpress 102 * Create new text file in OneDrive from the post created in the WordPress 103 * Find file/Folder by name in the WordPress 106 104 107 105 **Onedrive file sharing:** 108 106 109 * Enable onedrive file sharing for easy access of documents directly from WordPress. 110 * This one drive file sharing feature allows you to synchronise and supports migrations of documents bidirectionally between onedrive and WordPress. 107 *Enable onedrive file sharing for collaboration and easy access to documents directly from WordPress. 111 108 112 109 == Screenshots == … … 149 146 150 147 == ChangeLog == 148 149 = 2.3.0 = 150 * Compatibility with WordPress 6.6 151 * PHPCS Standards 152 * Fortified sanitization and escaping checks 153 * Fixed Security Warnings 151 154 152 155 = 2.2.9 = … … 297 300 == Upgrade Notice == 298 301 302 = 2.3.0 = 303 * Compatibility with WordPress 6.6 304 * PHPCS Standards 305 * Fortified sanitization and escaping checks 306 * Fixed Security Warnings 307 299 308 = 2.2.9 = 300 309 * Important bugfix in automatic connection. -
embed-sharepoint-onedrive-documents/trunk/uninstall.php
r3068620 r3157334 1 1 <?php 2 /** 3 * Handle deletion of the plugin related data and uninstall the plugin. 4 * 5 * @package embed-sharepoint-onedrive-documents 6 */ 2 7 3 if ( !defined( 'WP_UNINSTALL_PLUGIN' )) 4 exit(); 8 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { 9 exit(); 10 } 5 11 6 delete_option( 'mo_sps_application_config');7 delete_option( 'mo_sps_cloud_connector');8 delete_option( 'mo_sps_auth_code');9 delete_option( 'mo_sps_notice_message');10 delete_option( 'mo_sps_feedback_config');11 delete_option( 'mo_sps_all_sites');12 delete_option( 'mo_sps_plugin_migration_completed');13 delete_option( 'mo_sps_test_connection_user_details');14 delete_option( 'mo_sps_refresh_token');15 delete_option( 'mo_sps_test_connection_status');12 delete_option( 'mo_sps_application_config' ); 13 delete_option( 'mo_sps_cloud_connector' ); 14 delete_option( 'mo_sps_auth_code' ); 15 delete_option( 'mo_sps_notice_message' ); 16 delete_option( 'mo_sps_feedback_config' ); 17 delete_option( 'mo_sps_all_sites' ); 18 delete_option( 'mo_sps_plugin_migration_completed' ); 19 delete_option( 'mo_sps_test_connection_user_details' ); 20 delete_option( 'mo_sps_refresh_token' ); 21 delete_option( 'mo_sps_test_connection_status' );
Note: See TracChangeset
for help on using the changeset viewer.