Plugin Directory

Changeset 3157334


Ignore:
Timestamp:
09/25/2024 08:38:34 AM (18 months ago)
Author:
moazsup
Message:

PHPCS Changes, Sanitization & Escaping

Location:
embed-sharepoint-onedrive-documents
Files:
128 added
28 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • embed-sharepoint-onedrive-documents/trunk/embed-sharepoint-onedrive-documents.php

    r3102687 r3157334  
    11<?php
    2 
    32/*
    43Plugin Name: Embed SharePoint OneDrive Documents
    54Plugin 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.9
     5Description: 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.
     6Version: 2.3.0
    87Author: miniOrange
    9 License: GPLv2 or later
     8License: MIT
    109License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1110*/
    1211
    1312namespace 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
     14require_once __DIR__ . '/class-wp-namespace-autoloader.php';
     15
     16use MoSharePointObjectSync\View\AdminView;
     17use MoSharePointObjectSync\Controller\AdminController;
     18use MoSharePointObjectSync\Observer\AdminObserver;
     19use MoSharePointObjectSync\Observer\AppConfigObserver;
     20use MoSharePointObjectSync\Observer\DocumentObserver;
    2121use MoSharePointObjectSync\Observer\shortcodeSharepoint;
    2222
    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() {
     23use MoSharePointObjectSync\View\FeedbackForm;
     24use MoSharePointObjectSync\Wrappers\PluginConstants;
     25use MoSharePointObjectSync\Wrappers\WpWrapper;
     26
     27define( 'MO_SPS_PLUGIN_URL', plugins_url( '', __FILE__ ) );
     28define( 'MO_SPS_PLUGIN_VERSION', '2.2.9' );
     29define( 'MO_SPS_PLUGIN_FILE', __FILE__ );
     30/**
     31 * The main class ofEmbed SharePoint OneDrive Documents plugin.
     32 */
     33class 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() {
    3856        $this->mo_sps_load_hooks();
    3957    }
    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    }
    262339
    263340}
  • embed-sharepoint-onedrive-documents/trunk/includes/js/ajax.js

    r3091366 r3157334  
    343343      var web_url = ele.getAttribute('web-url');
    344344      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}`;
    346346        window.open(ajax_url, '_blank');
    347347      } else {
  • embed-sharepoint-onedrive-documents/trunk/readme.txt

    r3134861 r3157334  
    66Tested up to: 6.6
    77Requires PHP: 5.6
    8 Stable tag: 2.2.9
    9 License: GPLv2 or later
     8Stable tag: 2.3.0
     9License: MIT
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1111
     
    1414== Description ==
    1515
    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.
     16WordPress 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.
    1717
    1818[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.
    1919
    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.
     20You 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.
    2121
    2222== Features ==
     
    6666* Sync Office 365 Delve user profile attributes like About me, Skills, etc. to the WordPress site.
    6767* 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
    6969
    7070**Search SharePoint Files / Change View**
     
    8989* Retrieve/Synchronize list of all sharepoint sites in the WordPress
    9090* 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
    9292* Create new SharePoint site from the WordPress
    9393
     
    9595
    9696* Sync SharePoint social feeds like news and articles into the WordPress posts.
    97 * Useful for migrations and backup of social feed content.
    9897
    9998**Integration with OneDrive**
    10099
    101100* 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
    106104
    107105**Onedrive file sharing:**
    108106
    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.
    111108
    112109== Screenshots ==
     
    149146
    150147== 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
    151154
    152155= 2.2.9 =
     
    297300== Upgrade Notice ==
    298301
     302= 2.3.0 =
     303* Compatibility with WordPress 6.6
     304* PHPCS Standards
     305* Fortified sanitization and escaping checks
     306* Fixed Security Warnings
     307
    299308= 2.2.9 =
    300309* Important bugfix in automatic connection.
  • embed-sharepoint-onedrive-documents/trunk/uninstall.php

    r3068620 r3157334  
    11<?php
     2/**
     3 * Handle deletion of the plugin related data and uninstall the plugin.
     4 *
     5 * @package embed-sharepoint-onedrive-documents
     6 */
    27
    3 if ( !defined( 'WP_UNINSTALL_PLUGIN' ))
    4     exit();
     8if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
     9    exit();
     10}
    511
    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');
     12delete_option( 'mo_sps_application_config' );
     13delete_option( 'mo_sps_cloud_connector' );
     14delete_option( 'mo_sps_auth_code' );
     15delete_option( 'mo_sps_notice_message' );
     16delete_option( 'mo_sps_feedback_config' );
     17delete_option( 'mo_sps_all_sites' );
     18delete_option( 'mo_sps_plugin_migration_completed' );
     19delete_option( 'mo_sps_test_connection_user_details' );
     20delete_option( 'mo_sps_refresh_token' );
     21delete_option( 'mo_sps_test_connection_status' );
Note: See TracChangeset for help on using the changeset viewer.