Warning: Constant SEO_LINKS_API_ENDPOINT already defined in /www/wwwroot/fni.gov.mz/wp-content/plugins/wordpress-plugin/wordpress-plugin.php on line 10
HEX
HEX
Server: Apache
System: Linux paginas.localdomain 4.15.0-200-generic #211-Ubuntu SMP Thu Nov 24 18:16:04 UTC 2022 x86_64
User: www (1002)
PHP: 8.0.11
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/fni.gov.mz/wp-content/plugins/td-composer/includes/tdc_guttenberg.php
<?php
/**
 * Created by PhpStorm.
 * User: lucian
 * Date: 8/22/2018
 * Time: 8:53 AM
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly.
}

class tdc_guttenberg {

    protected $is_gutenberg_editor_active = false;
    protected $show_on_this_post_type = false;
    protected $post_id = null;
    protected $post_type = null;

    public static function is_gutenberg() {
        return function_exists( 'the_gutenberg_project' );
    }

    public function tdc_enqueue_assets() {
        $this->is_gutenberg_editor_active = true;
        $this->post_id = get_the_ID();
        $this->post_type = get_post_type( $this->post_id );

        $show_on_post_types = array( 'page' );

        if ( $this->post_type and in_array( $this->post_type, $show_on_post_types ) ) {
            $this->show_on_this_post_type = true;
        }

        $tdc_settings = [
            'tdcEditLink' => tdc_util::get_edit_link( $this->post_id ),
        ];

        if ( TDC_DEPLOY_MODE == 'deploy' ) {
            wp_enqueue_script( 'js_files_for_gutenberg_editor', TDC_URL . '/assets/js/js_files_for_gutenberg_editor.min.js', array('jquery'), TD_COMPOSER, true );
            wp_localize_script( 'js_files_for_gutenberg_editor', 'tdcGutenbergSettings', $tdc_settings );
        } else {
            wp_enqueue_script( 'tdcGutenberg', TDC_URL . '/assets/js/tdcGutenberg.js', array('jquery'), TD_COMPOSER, true );
            wp_localize_script( 'tdcGutenberg', 'tdcGutenbergSettings', $tdc_settings );
        }
    }

    public function tdc_add_admin_switch_button() {
        if ( ! $this->is_gutenberg_editor_active or ! $this->show_on_this_post_type ) {
            return;
        }

        echo '
        <script id="tdc-gutenberg-button-switch" type="text/html">
            <div class="tdc-panel-button">
                <div class="tdc-panel-icon"></div>
                <div class="tdc-panel-link">
                    <a id="tdc-switch-button" href="' . tdc_util::get_edit_link( $this->post_id ) . '">TagDiv Composer</a>
                </div>
            </div>
        </script>';
    }

    public function __construct() {
        add_action( 'enqueue_block_editor_assets', [ $this, 'tdc_enqueue_assets' ] );
        add_action( 'admin_footer', [ $this, 'tdc_add_admin_switch_button' ] );
    }

}