Plugin Directory

Changeset 3204097


Ignore:
Timestamp:
12/07/2024 02:23:40 PM (16 months ago)
Author:
globaliser
Message:

Version 0.9.3 Wpml Support Added

Location:
globaliser
Files:
82 added
8 edited

Legend:

Unmodified
Added
Removed
  • globaliser/trunk/app/controllers/language-controller.php

    r3202469 r3204097  
    33namespace Globaliser;
    44
    5 use \WP_Query;
    6 
    75class LanguageController extends Controller
    86{
    97    private $service = null;
     8    private $active_plugins = null;
    109
    1110    public function __construct()
    1211    {
    1312        parent::__construct();
     13        $this->active_plugins = get_option('active_plugins');
    1414        $this->main();
    1515    }
     
    1717    public function main()
    1818    {
    19         $active_plugins = get_option('active_plugins');
     19        $this->wpml_set_if_active();
     20        $this->polylang_set_if_active();
     21    }
    2022
    21         // Polylang is active
    22         if (in_array('polylang/polylang.php', $active_plugins)) {
     23    private function polylang_set_if_active()
     24    {
     25        if (in_array(POLYLANG, $this->active_plugins)) {
    2326            $this->service = new PolylangService();
    2427        }
    25 
    26         if ($this->service !== null) $this->bind();
    2728    }
    2829
    29     private function bind()
     30    private function wpml_set_if_active()
    3031    {
    31         $this->filter('rest_post_dispatch', 'restapi_totalpages_fix', 10, 3);
    32     }
    33 
    34     public function restapi_totalpages_fix($response, $server, $request)
    35     {
    36         return $this->service->restapi_totalpages_fix($response, $server, $request);
     32        if (in_array(WPML, $this->active_plugins)) {
     33            $this->service = new WpmlService();
     34        }
    3735    }
    3836
    3937    public function get_languages()
    4038    {
    41         return $this->service->get_languages();
     39        return $this->service === null ? null : $this->service->get_languages();
    4240    }
    4341}
  • globaliser/trunk/app/models/general-model.php

    r3202469 r3204097  
    2020    function get_authors()
    2121    {
    22         return $this->db->get_results("SELECT u.ID, u.user_login, COUNT(p.post_author) AS 'post_count' FROM wp_users as u INNER JOIN wp_posts as p ON u.ID = p.post_author WHERE  p.post_type = 'post' AND p.post_status = 'publish' GROUP BY u.ID ");
     22        $query = "SELECT u.ID, u.user_login, COUNT(p.post_author) AS 'post_count' FROM " . $this->db->prefix . "users as u " .
     23            " INNER JOIN " . $this->db->prefix . "posts as p ON u.ID = p.post_author " .
     24            " WHERE p.post_type = 'post' AND p.post_status = 'publish' " .
     25            " GROUP BY u.ID ";
     26        return $this->db->get_results($query);
    2327    }
    2428}
  • globaliser/trunk/app/services/polylang-service.php

    r3202469 r3204097  
    55use \WP_Query;
    66
    7 class PolylangService
     7class PolylangService extends Controller
    88{
    9     function __construct() {}
     9    private $plugin_info = null;
     10    function __construct()
     11    {
     12        parent::__construct();
     13        $this->main();
     14    }
     15
     16    public function main()
     17    {
     18        $this->set_plugin_info();
     19        $this->filter('rest_post_dispatch', 'restapi_totalpages', 10, 3);
     20    }
     21    private function set_plugin_info()
     22    {
     23        require_once(ABSPATH . 'wp-admin/includes/plugin.php');
     24        $this->plugin_info = get_plugin_data(WP_PLUGIN_DIR . "/" . POLYLANG, false, false);
     25    }
    1026
    1127    public function get_languages()
    1228    {
    1329        $data = [];
    14         $languages_list = PLL()->model->get_languages_list();
    1530
    16         foreach ($languages_list as $lang) {
     31        $languages = PLL()->model->get_languages_list();
     32
     33        foreach ($languages as $lang) {
    1734
    1835            $lang->link = get_term_link($lang->term_id, 'language');
    19             $lang->plugin = 'polylang';
    20             $data[] = $lang;
    2136        }
     37
     38        $data['plugin'] = 'polylang';
     39        $data['plugin_version'] = $this->plugin_info['Version'];
     40        $data['languages'] = $languages;
    2241
    2342        return $data;
    2443    }
    2544
    26     public function restapi_totalpages_fix($response, $server, $request)
     45    public function restapi_totalpages($response, $server, $request)
    2746    {
    2847
  • globaliser/trunk/constants/general.php

    r3202469 r3204097  
    11<?php
    22
    3 // If this file is called directly, abort. //
    4 if (!defined('WPINC')) die;
     3namespace Globaliser;
    54
    65global $wpdb;
    76
    8 define('GLOBALISER_TABLE_HOOKS', $wpdb->prefix . 'globaliser_hooks');
     7define('Globaliser\GLOBALISER_TABLE_HOOKS', $wpdb->prefix . 'globaliser_hooks');
  • globaliser/trunk/constants/hooks-settings.php

    r3202469 r3204097  
    11<?php
    22
    3 // If this file is called directly, abort. //
    4 if (!defined('WPINC')) die;
     3namespace Globaliser;
    54
    6 define('GLOBALISER_GENERAL_HOOKS', [
     5define('Globaliser\GLOBALISER_GENERAL_HOOKS', [
    76    ['customize_save_after'],
    87    ['wp_update_nav_menu'],
     
    1413
    1514define(
    16     'GLOBALISER_SETTINGS_HOOKS',
     15    'Globaliser\GLOBALISER_SETTINGS_HOOKS',
    1716    array(
    1817        'blogname',
  • globaliser/trunk/globaliser.php

    r3202469 r3204097  
    44   Plugin URI: https://www.globaliser.com/wordpress-hosting/
    55   Description:  This plugin enables Globaliser Cloud Speed, Security, and Reliability features for WordPress sites. It is intended for Globaliser clients to ensure optimal performance and compatibility with Globaliser services.
    6    Version: 0.9.2
     6   Version: 0.9.3
    77   Author: Globaliser, Inc.
    88   Author URI: https://www.globaliser.com
  • globaliser/trunk/inc/default.php

    r3202469 r3204097  
    1919require_once PLUGIN_PATH . '/constants/general.php';
    2020require_once PLUGIN_PATH . '/constants/hooks-settings.php';
     21require_once PLUGIN_PATH . '/constants/plugins.php';
    2122
    2223// Helpers
  • globaliser/trunk/readme.txt

    r3202469 r3204097  
    55License: GPLv2 or later
    66Tested up to: 6.7.1
    7 Stable tag: 0.9.2
     7Stable tag: 0.9.3
    88Requires PHP: 8.1
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2828== Changelog ==
    2929
     30= 0.9.3 =
     31* WPML support added.
     32
    3033= 0.9.2 =
    3134* Bugfixes related to caching and polylang integration
Note: See TracChangeset for help on using the changeset viewer.