Initial commit: Atomaste website
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "docker" # See documentation for possible values
|
||||
directories:
|
||||
- "**/*" # Location of package manifests
|
||||
labels:
|
||||
- "dependencies"
|
||||
- "docker"
|
||||
reviewers:
|
||||
- "hostinger/wp-devs"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
@@ -0,0 +1,11 @@
|
||||
name: sca-scan
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [master, main, staging]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
run-sca:
|
||||
uses: hostinger/sca-configs/.github/workflows/sca.yml@main
|
||||
secrets: inherit
|
||||
@@ -0,0 +1,124 @@
|
||||
# WordPress Menu Manager PHP package
|
||||
|
||||
Package for managing Hostinger Amplitude events.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Installation](#installation)
|
||||
- [Usage](#usage)
|
||||
- [Code Testing](#code-testing)
|
||||
- [Support](#support)
|
||||
|
||||
## Installation
|
||||
|
||||
This is private package, adding it to composer is a bit different.
|
||||
|
||||
Add it to the composer.json:
|
||||
```sh
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "git@github.com:hostinger/hostinger-wp-amplitude.git"
|
||||
}
|
||||
],
|
||||
```
|
||||
|
||||
and:
|
||||
```sh
|
||||
"require": {
|
||||
"hostinger/hostinger-wp-amplitude": "dev-main",
|
||||
}
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
First thing boot up package in main plugin file:
|
||||
|
||||
```sh
|
||||
use Hostinger\Amplitude\AmplitudeLoader;
|
||||
|
||||
if( !function_exists('hostinger_load_amplitude') ) {
|
||||
function hostinger_load_amplitude(): void {
|
||||
$amplitude = AmplitudeLoader::getInstance();
|
||||
$amplitude->boot();
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! has_action( 'plugins_loaded', 'hostinger_load_amplitude' ) ) {
|
||||
add_action('plugins_loaded', 'hostinger_load_amplitude');
|
||||
}
|
||||
```
|
||||
|
||||
You are ready to go. There are several hooks for use.
|
||||
|
||||
**getSingleAmplitudeEvents** - Add amplitude events that should trigger only once per day.
|
||||
|
||||
```sh
|
||||
add_filter('hostinger_once_per_day_events', function($amplitudeEvents) {
|
||||
$eventsList = [
|
||||
'wordpress.home.enter',
|
||||
'wordpress.learn.enter',
|
||||
'wordpress.ai_assistant.enter',
|
||||
];
|
||||
|
||||
$amplitudeEvents = array_merge($amplitudeEvents, $eventsList)
|
||||
|
||||
return $amplitudeEvents;
|
||||
});
|
||||
```
|
||||
|
||||
**SendRequest** - Submit amplitude event from backend.
|
||||
|
||||
```sh
|
||||
namespace Hostinger\Amplitude;
|
||||
|
||||
use Hostinger\Amplitude\AmplitudeManager;
|
||||
use Hostinger\WpHelper\Utils as Helper;
|
||||
use Hostinger\WpHelper\Requests\Client;
|
||||
use Hostinger\WpHelper\Config;
|
||||
use Hostinger\WpHelper\Constants;
|
||||
|
||||
$helper = new Helper();
|
||||
$configHandler = new Config();
|
||||
$client = new Client(
|
||||
$configHandler->getConfigValue( 'base_rest_uri', Constants::HOSTINGER_REST_URI ),
|
||||
array(
|
||||
Config::TOKEN_HEADER => $helper::getApiToken(),
|
||||
Config::DOMAIN_HEADER => $helper->getHostInfo()
|
||||
)
|
||||
);
|
||||
|
||||
$params = [
|
||||
'action' => 'wp_admin.woocommerce_onboarding.setup_store',
|
||||
'location' => 'wordpress',
|
||||
]
|
||||
|
||||
$amplitudeManger = new AmplitudeManager( $helper, $configHandler, $client );
|
||||
$amplitudeManger->sendRequest( $amplitudeManger::AMPLITUDE_ENDPOINT, $params );
|
||||
```
|
||||
|
||||
**SendRequest** - Submit amplitude event from frontend.
|
||||
|
||||
```sh
|
||||
var data = {
|
||||
action: 'yourAction',
|
||||
location: 'yourLocation'
|
||||
};
|
||||
|
||||
fetch('https://yourWebsiteUrl/wp-json/hostinger-amplitude/v1/hostinger-amplitude-event', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => console.log(data))
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
Package initially was written by Martynas Umbraziunas (martynas.umbraziunas@hostinger.com). You can ping him in Slack for support.
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "hostinger/hostinger-wp-amplitude",
|
||||
"description": "A PHP package with amplitude events for WordPress plugins",
|
||||
"license": "proprietary",
|
||||
"type": "library",
|
||||
"version": "1.0.12",
|
||||
"require": {
|
||||
"php": ">=8.0",
|
||||
"hostinger/hostinger-wp-helper": "dev-main"
|
||||
},
|
||||
"require-dev": {
|
||||
"squizlabs/php_codesniffer": "^3.0",
|
||||
"phpunit/phpunit": "^9.6"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "git@github.com:hostinger/hostinger-wp-helper.git"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Hostinger\\Amplitude\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Hostinger\\Amplitude\\Tests\\": "tests/phpunit"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace Hostinger\Amplitude;
|
||||
|
||||
use Hostinger\Amplitude\AmplitudeManager;
|
||||
use Hostinger\WpHelper\Config;
|
||||
use Hostinger\WpHelper\Requests\Client;
|
||||
use Hostinger\WpHelper\Utils as Helper;
|
||||
|
||||
class ActionDispatcher
|
||||
{
|
||||
private const TRANSIENT_KEY = 'hostinger_login_data';
|
||||
private const EXPIRATION_TIME_SECONDS = 10800; // 3 hours
|
||||
private const AMPLITUDE_LOGIN_ACTION = 'wordpress.autologin.success';
|
||||
|
||||
private Config $configHandler;
|
||||
private Client $client;
|
||||
private Helper $helper;
|
||||
|
||||
public function __construct(
|
||||
Helper $helper,
|
||||
Config $configHandler,
|
||||
Client $client
|
||||
) {
|
||||
$this->helper = $helper;
|
||||
$this->configHandler = $configHandler;
|
||||
$this->client = $client;
|
||||
|
||||
add_action( 'hostinger_autologin_user_logged_in', [ $this, 'userAlreadyLoggedIn' ] );
|
||||
add_action( 'hostinger_autologin', [ $this, 'handleAutoLogin' ] );
|
||||
add_action( 'wp_logout', [ $this, 'clearLoginData' ] );
|
||||
}
|
||||
|
||||
public function handleAutoLogin( array $data ) : void {
|
||||
$this->processLoginData( $data );
|
||||
$this->loginEvent( $this->helper, $this->configHandler, $this->client, 'new_login' );
|
||||
}
|
||||
|
||||
public function userAlreadyLoggedIn( array $data ) : void {
|
||||
$this->processLoginData( $data );
|
||||
$this->loginEvent( $this->helper, $this->configHandler, $this->client, 'logged_in' );
|
||||
}
|
||||
|
||||
|
||||
public function processLoginData( array $data ) : void {
|
||||
$sanitized_data = $this->sanitizeLoginData( $data );
|
||||
set_transient( self::TRANSIENT_KEY, $sanitized_data, self::EXPIRATION_TIME_SECONDS );
|
||||
}
|
||||
|
||||
public function loginEvent( Helper $helper, Config $config, Client $client, string $status ) : void {
|
||||
$amplitudeManager = new AmplitudeManager( $helper, $config, $client );
|
||||
$params = [
|
||||
'action' => self::AMPLITUDE_LOGIN_ACTION,
|
||||
'status' => $status,
|
||||
];
|
||||
|
||||
$amplitudeManager->sendRequest( $amplitudeManager::AMPLITUDE_ENDPOINT, $params );
|
||||
}
|
||||
|
||||
private function sanitizeLoginData( array $data ) : array {
|
||||
if ( ! is_array( $data ) ) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return array_map( 'sanitize_text_field', $data );
|
||||
}
|
||||
|
||||
public function clearLoginData() : void {
|
||||
delete_transient( self::TRANSIENT_KEY );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace Hostinger\Amplitude;
|
||||
|
||||
use Hostinger\WpHelper\Config;
|
||||
use Hostinger\WpHelper\Constants;
|
||||
use Hostinger\WpHelper\Requests\Client;
|
||||
use Hostinger\WpHelper\Utils as Helper;
|
||||
|
||||
class AmplitudeLoader
|
||||
{
|
||||
/**
|
||||
* @var AmplitudeLoader instance.
|
||||
*/
|
||||
private static ?AmplitudeLoader $instance = null;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private array $objects = [];
|
||||
|
||||
/**
|
||||
* Allow only one instance of class
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function getInstance() : self {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function boot() : bool {
|
||||
$this->registerModules();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function registerModules() : void {
|
||||
// Action Dispatcher.
|
||||
$helper = new Helper();
|
||||
$config = new Config();
|
||||
$client = new Client(
|
||||
$config->getConfigValue( 'base_rest_uri', Constants::HOSTINGER_REST_URI ), [
|
||||
Config::TOKEN_HEADER => $helper->getApiToken(),
|
||||
Config::DOMAIN_HEADER => $helper->getHostInfo(),
|
||||
]
|
||||
);
|
||||
|
||||
$this->objects['action_dispatcher'] = new ActionDispatcher( $helper, $config, $client );
|
||||
|
||||
// Amplitude Manager.
|
||||
$this->objects['amplitude_rest'] = new Rest();
|
||||
$this->objects['amplitude_rest']->init();
|
||||
|
||||
$this->addContainer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function addContainer() : bool {
|
||||
if ( empty( $this->objects ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ( $this->objects as $object ) {
|
||||
if ( property_exists( $object, 'amplitude' ) ) {
|
||||
$object->setAmplitude( $this );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPluginInfo() : string {
|
||||
$plugin_url = '';
|
||||
|
||||
$plugins = get_plugins();
|
||||
foreach ( $plugins as $plugin_path => $plugin_info ) {
|
||||
if ( str_contains( __FILE__, 'plugins/' . dirname( $plugin_path ) . '/' ) ) {
|
||||
$plugin_dir = dirname( $plugin_path );
|
||||
|
||||
return plugins_url( $plugin_dir );
|
||||
}
|
||||
}
|
||||
|
||||
return $plugin_url;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace Hostinger\Amplitude;
|
||||
|
||||
use Hostinger\WpHelper\Config;
|
||||
use Hostinger\WpHelper\Requests\Client;
|
||||
use Hostinger\WpHelper\Utils as Helper;
|
||||
|
||||
class AmplitudeManager
|
||||
{
|
||||
public const AMPLITUDE_ENDPOINT = '/v3/wordpress/plugin/trigger-event';
|
||||
private const CACHE_ONE_DAY = 86400;
|
||||
private const LOGIN_DATA = 'hostinger_login_data';
|
||||
|
||||
private Config $configHandler;
|
||||
private Client $client;
|
||||
private Helper $helper;
|
||||
|
||||
public function __construct(
|
||||
Helper $helper,
|
||||
Config $configHandler,
|
||||
Client $client
|
||||
) {
|
||||
$this->helper = $helper;
|
||||
$this->configHandler = $configHandler;
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
public function sendRequest( string $endpoint, array $params ) : array {
|
||||
try {
|
||||
if ( ! $this->isTransientSystemWorking() ) {
|
||||
return [ 'status' => 'error', 'message' => 'Database error: Transient not set correctly' ];
|
||||
}
|
||||
|
||||
if ( ! $this->shouldSendAmplitudeEvent( $params ) ) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$params = $this->addImpersonationData( $params );
|
||||
$params = $this->addDomainAndDirectory( $params );
|
||||
|
||||
$response = $this->client->post( $endpoint, [ 'params' => $params ] );
|
||||
|
||||
return $response;
|
||||
} catch ( \Exception $exception ) {
|
||||
$this->helper->errorLog( 'Error sending request: ' . $exception->getMessage() );
|
||||
|
||||
return [ 'status' => 'error', 'message' => $exception->getMessage() ];
|
||||
}
|
||||
}
|
||||
|
||||
public function addDomainAndDirectory( array $params ) : array {
|
||||
if ( $siteUrl = get_site_url() ) {
|
||||
$params['siteurl'] = $siteUrl;
|
||||
|
||||
$websiteDir = $this->getSubdirectoryName( $siteUrl );
|
||||
$params['directory'] = $websiteDir;
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function getSubdirectoryName( string $siteUrl ) : string {
|
||||
$sitePath = parse_url( $siteUrl, PHP_URL_PATH ) ?? '';
|
||||
|
||||
return trim( $sitePath, '/' ) ? : '';
|
||||
}
|
||||
|
||||
public function addImpersonationData( array $params ) : array {
|
||||
$login_data = get_transient( self::LOGIN_DATA );
|
||||
|
||||
if ( $login_data === false ) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
if ( ! empty( $login_data['acting_client_id'] ) ) {
|
||||
$params['is_impersonated'] = true;
|
||||
$params['impersonated_client_id'] = sanitize_text_field( $login_data['acting_client_id'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $login_data['client_id'] ) ) {
|
||||
$params['client_id'] = sanitize_text_field( $login_data['client_id'] );
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
// Events which firing once per day
|
||||
public static function getSingleAmplitudeEvents() : array {
|
||||
return apply_filters( 'hostinger_once_per_day_events', [] );
|
||||
}
|
||||
|
||||
public function shouldSendAmplitudeEvent( array $params ): bool {
|
||||
$oneTimePerDay = self::getSingleAmplitudeEvents();
|
||||
|
||||
if ( empty( $params['action'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$eventAction = sanitize_text_field( $params['action'] );
|
||||
$transientKey = 'amplitude_event_' . $eventAction;
|
||||
|
||||
if ( in_array( $eventAction, $oneTimePerDay, true ) ) {
|
||||
$hasBeenSentToday = get_transient( $transientKey );
|
||||
|
||||
if ( $hasBeenSentToday ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
set_transient( $transientKey, time(), self::CACHE_ONE_DAY );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isTransientSystemWorking() : bool {
|
||||
set_transient( 'check_transients', 'value', 60 );
|
||||
|
||||
$testValue = get_transient( 'check_transients' );
|
||||
|
||||
return $testValue !== false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
/**
|
||||
* Rest API Routes
|
||||
*
|
||||
* @package HostingerAffiliatePlugin
|
||||
*/
|
||||
|
||||
namespace Hostinger\Amplitude;
|
||||
|
||||
use Hostinger\WpHelper\Utils as Helper;
|
||||
use Hostinger\WpHelper\Requests\Client;
|
||||
use Hostinger\WpHelper\Config;
|
||||
use Hostinger\WpHelper\Constants;
|
||||
|
||||
|
||||
/**
|
||||
* Avoid possibility to get file accessed directly
|
||||
*/
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for handling Rest Api Routes
|
||||
*/
|
||||
class Rest {
|
||||
public const REST_NAMESPACE = 'hostinger-amplitude/v1';
|
||||
|
||||
/**
|
||||
* @var Helper
|
||||
*/
|
||||
private Helper $helper;
|
||||
|
||||
/**
|
||||
* @var Config
|
||||
*/
|
||||
private Config $configHandler;
|
||||
|
||||
/**
|
||||
* @var Client
|
||||
*/
|
||||
private Client $client;
|
||||
|
||||
public function __construct() {
|
||||
$this->helper = new Helper();
|
||||
$this->configHandler = new Config();
|
||||
$this->client = new Client(
|
||||
$this->configHandler->getConfigValue( 'base_rest_uri', Constants::HOSTINGER_REST_URI ),
|
||||
array(
|
||||
Config::TOKEN_HEADER => $this->helper::getApiToken(),
|
||||
Config::DOMAIN_HEADER => $this->helper->getHostInfo()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Init rest routes
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void {
|
||||
add_action( 'rest_api_init', [ $this, 'registerRoutes' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function registerRoutes(): void {
|
||||
$this->registerAmplitudeRoute();
|
||||
$this->registerExperimentsRoute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function registerAmplitudeRoute(): void {
|
||||
register_rest_route(
|
||||
self::REST_NAMESPACE,
|
||||
'hostinger-amplitude-event',
|
||||
array(
|
||||
'methods' => 'POST',
|
||||
'callback' => array( $this, 'sendAmplitudeEvent' ),
|
||||
'permission_callback' => array( $this, 'permissionCheck' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function registerExperimentsRoute(): void {
|
||||
register_rest_route(
|
||||
self::REST_NAMESPACE,
|
||||
'hostinger-amplitude-experiments',
|
||||
array(
|
||||
'methods' => 'GET',
|
||||
'callback' => array( $this, 'getExperiments' ),
|
||||
'permission_callback' => array( $this, 'permissionCheck' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \WP_REST_Response
|
||||
*/
|
||||
public function getExperiments( ): \WP_REST_Response {
|
||||
$data = array();
|
||||
|
||||
$response = new \WP_REST_Response( );
|
||||
|
||||
try {
|
||||
$response->set_status( \WP_Http::OK );
|
||||
|
||||
$request = $this->client->get( '/v3/wordpress/amplitude/experiments', array( 'domain' => $this->helper->getHostInfo() ) );
|
||||
|
||||
$data = $request;
|
||||
|
||||
if(!empty($request['body'])) {
|
||||
$json = json_decode($request['body'], true);
|
||||
|
||||
if(!empty($json['data'])) {
|
||||
$data = array(
|
||||
'status' => 'success',
|
||||
'data' => $json['data']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
} catch ( \Exception $exception ) {
|
||||
|
||||
$response->set_status( \WP_Http::BAD_REQUEST );
|
||||
|
||||
$this->helper->errorLog( 'Error sending request: ' . $exception->getMessage() );
|
||||
|
||||
$data = array(
|
||||
'status' => 'error',
|
||||
'message' => $exception->getMessage()
|
||||
);
|
||||
}
|
||||
|
||||
$response->set_data( $data );
|
||||
|
||||
$response->set_headers( array( 'Cache-Control' => 'no-cache' ) );
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function sendAmplitudeEvent( $request ) {
|
||||
$params = $request->get_param( 'params' );
|
||||
|
||||
$amplitudeManger = new AmplitudeManager( $this->helper, $this->configHandler, $this->client );
|
||||
$status = $amplitudeManger->sendRequest( $amplitudeManger::AMPLITUDE_ENDPOINT, !empty($params) ? $params : [] );
|
||||
|
||||
$response = new \WP_REST_Response( array( 'status' => $status ) );
|
||||
$response->set_headers(array('Cache-Control' => 'no-cache'));
|
||||
$response->set_status( \WP_Http::OK );
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WP_REST_Request $request WordPress rest request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function permissionCheck( $request ): bool {
|
||||
if ( empty( is_user_logged_in() ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Implement custom capabilities when needed.
|
||||
return current_user_can( 'manage_options' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "docker" # See documentation for possible values
|
||||
directories:
|
||||
- "**/*" # Location of package manifests
|
||||
labels:
|
||||
- "dependencies"
|
||||
- "docker"
|
||||
reviewers:
|
||||
- "hostinger/wp-devs"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
@@ -0,0 +1,11 @@
|
||||
name: sca-scan
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [master, main, staging]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
run-sca:
|
||||
uses: hostinger/sca-configs/.github/workflows/sca.yml@main
|
||||
secrets: inherit
|
||||
@@ -0,0 +1,45 @@
|
||||
# WordPress Core functions for plugins PHP package
|
||||
|
||||
A PHP package with core functions for Hostinger WordPress plugins.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Installation](#installation)
|
||||
- [Usage](#usage)
|
||||
- [Support](#support)
|
||||
|
||||
## Installation
|
||||
|
||||
This is private package, adding it to composer is a bit different.
|
||||
|
||||
Add it to the composer.json:
|
||||
```sh
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "git@github.com:hostinger/hostinger-wp-helper.git"
|
||||
}
|
||||
],
|
||||
```
|
||||
|
||||
and:
|
||||
```sh
|
||||
"require": {
|
||||
"hostinger/hostinger-wp-helper": "main",
|
||||
}
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
First thing boot up package in main plugin file:
|
||||
|
||||
```sh
|
||||
use Hostinger\Helper;
|
||||
|
||||
$helepr = new Helper();
|
||||
$helper->isPreviewDomain();
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
Package initially was written by Martynas U. (martynas.umbraziunas@hostinger.com). You can ping him in Slack for support.
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "hostinger/hostinger-wp-helper",
|
||||
"description": "A PHP package with core functions for Hostinger WordPress plugins.",
|
||||
"type": "library",
|
||||
"require": {
|
||||
"php": ">=8.0",
|
||||
"ext-json": "*"
|
||||
},
|
||||
"version": "1.0.10",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Hostinger\\WpHelper\\": "src/",
|
||||
"Hostinger\\Tests\\": "tests/phpunit"
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.6",
|
||||
"yoast/phpunit-polyfills": "^2.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Hostinger\WpHelper;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Config {
|
||||
private array $config = array();
|
||||
public const TOKEN_HEADER = 'X-Hpanel-Order-Token';
|
||||
public const DOMAIN_HEADER = 'X-Hpanel-Domain';
|
||||
public const CONFIG_PATH = ABSPATH . '.private/config.json';
|
||||
public function __construct() {
|
||||
$this->decodeConfig( self::CONFIG_PATH );
|
||||
}
|
||||
|
||||
private function decodeConfig( string $path ): void {
|
||||
if ( file_exists( $path ) ) {
|
||||
$config_content = file_get_contents( $path );
|
||||
$this->config = json_decode( $config_content, true );
|
||||
}
|
||||
}
|
||||
|
||||
public function getConfigValue( string $key, $default ): string {
|
||||
if ( $this->config && isset( $this->config[ $key ] ) && ! empty( $this->config[ $key ] ) ) {
|
||||
return $this->config[ $key ];
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Hostinger\WpHelper;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Constants {
|
||||
public const TOKEN_HEADER = 'X-Hpanel-Order-Token';
|
||||
public const DOMAIN_HEADER = 'X-Hpanel-Domain';
|
||||
public const HOSTINGER_REST_URI = 'https://rest-hosting.hostinger.com';
|
||||
public const CONFIG_PATH = ABSPATH . '.private/config.json';
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Hostinger\WpHelper\Requests;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Client {
|
||||
private string $api_url;
|
||||
private array $default_headers;
|
||||
|
||||
public function __construct( $api_url, $default_headers = array() ) {
|
||||
$this->api_url = $api_url;
|
||||
$this->default_headers = $default_headers;
|
||||
}
|
||||
|
||||
public function get_api_url(): string {
|
||||
return $this->api_url;
|
||||
}
|
||||
|
||||
public function set_api_url( string $api_url ): void {
|
||||
$this->api_url = $api_url;
|
||||
}
|
||||
|
||||
public function get_default_headers(): array {
|
||||
return $this->default_headers;
|
||||
}
|
||||
|
||||
public function set_default_headers( array $default_headers ): void {
|
||||
$this->default_headers = $default_headers;
|
||||
}
|
||||
|
||||
public function get( $endpoint, $params = array(), $headers = array(), $timeout = 120 ) {
|
||||
$url = $this->api_url . $endpoint;
|
||||
$request_args = array(
|
||||
'method' => 'GET',
|
||||
'headers' => array_merge( $this->default_headers, $headers ),
|
||||
'timeout' => $timeout,
|
||||
);
|
||||
|
||||
if ( ! empty( $params ) ) {
|
||||
$url = add_query_arg( $params, $url );
|
||||
}
|
||||
|
||||
$response = wp_remote_get( $url, $request_args );
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function post( $endpoint, $params = array(), $headers = array(), $timeout = 120 ) {
|
||||
$url = $this->api_url . $endpoint;
|
||||
$request_args = array(
|
||||
'method' => 'POST',
|
||||
'timeout' => $timeout,
|
||||
'headers' => array_merge( $this->default_headers, $headers ),
|
||||
'body' => $params,
|
||||
);
|
||||
|
||||
$response = wp_remote_post( $url, $request_args );
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
<?php
|
||||
|
||||
namespace Hostinger\WpHelper;
|
||||
|
||||
class Utils {
|
||||
|
||||
private static string $apiTokenFile;
|
||||
|
||||
private const HPANEL_DOMAIN_URL = 'https://hpanel.hostinger.com/websites/';
|
||||
private const HOSTINGER_SITE = '.hostingersite.com';
|
||||
|
||||
private static function getApiTokenPath(): void {
|
||||
$hostingerDirParts = explode( '/', __DIR__ );
|
||||
if ( count( $hostingerDirParts ) >= 3 ) {
|
||||
$hostingerServerRootPath = '/' . $hostingerDirParts[1] . '/' . $hostingerDirParts[2];
|
||||
self::$apiTokenFile = $hostingerServerRootPath . '/.api_token';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pluginSlug
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
// Check if a specific plugin is active by its slug
|
||||
public static function isPluginActive( string $pluginSlug ): bool {
|
||||
$plugin_relative_path = $pluginSlug . '/' . $pluginSlug . '.php';
|
||||
|
||||
if ( is_multisite() ) {
|
||||
return self::checkIsPluginActiveMultiSite( $plugin_relative_path );
|
||||
}
|
||||
|
||||
return self::checkIsPluginActive( $plugin_relative_path );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $plugin_relative_path
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkIsPluginActiveMultiSite( string $plugin_relative_path ): bool {
|
||||
// Check network-wide active plugins
|
||||
$activePlugins = get_site_option( 'active_sitewide_plugins', [] );
|
||||
if ( in_array( $plugin_relative_path, $activePlugins ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check each site in the network
|
||||
$sites = get_sites();
|
||||
foreach ( $sites as $site ) {
|
||||
switch_to_blog( $site->blog_id );
|
||||
$activePlugins = get_option( 'active_plugins', [] );
|
||||
if ( in_array( $plugin_relative_path, $activePlugins ) ) {
|
||||
restore_current_blog();
|
||||
|
||||
return true;
|
||||
}
|
||||
restore_current_blog();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $plugin_relative_path
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkIsPluginActive( string $plugin_relative_path ): bool {
|
||||
// Check active plugins in a single site
|
||||
$activePlugins = get_option( 'active_plugins', [] );
|
||||
|
||||
if ( in_array( $plugin_relative_path, $activePlugins ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the content of the API token file
|
||||
public static function getApiToken(): string {
|
||||
self::getApiTokenPath();
|
||||
|
||||
if ( file_exists( self::$apiTokenFile ) ) {
|
||||
$apiToken = file_get_contents( self::$apiTokenFile );
|
||||
if ( ! empty( $apiToken ) ) {
|
||||
return $apiToken;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
// Get the host info (domain, subdomain, subdirectory)
|
||||
public function getHostInfo(): string {
|
||||
$host = $_SERVER['HTTP_HOST'] ?? '';
|
||||
$site_url = get_site_url();
|
||||
$site_url = preg_replace( '#^https?://#', '', $site_url );
|
||||
|
||||
if ( ! empty( $site_url ) && ! empty( $host ) && strpos( $site_url, $host ) === 0 ) {
|
||||
if ( $site_url === $host ) {
|
||||
return $host;
|
||||
} else {
|
||||
return substr( $site_url, strlen( $host ) + 1 );
|
||||
}
|
||||
}
|
||||
|
||||
return $host;
|
||||
}
|
||||
|
||||
// Check if the current domain is a preview domain
|
||||
public function isPreviewDomain(): bool {
|
||||
if ( function_exists( 'getallheaders' ) ) {
|
||||
$headers = getallheaders();
|
||||
}
|
||||
|
||||
if ( isset( $headers['X-Preview-Indicator'] ) && $headers['X-Preview-Indicator'] ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the current page is the specified page
|
||||
public function isThisPage( string $page ): bool {
|
||||
|
||||
if ( ! isset( $_SERVER['REQUEST_URI'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$current_uri = sanitize_text_field( $_SERVER['REQUEST_URI'] );
|
||||
|
||||
if ( defined( 'DOING_AJAX' ) && \DOING_AJAX ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( isset( $current_uri ) && strpos( $current_uri, '/wp-json/' ) !== false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( strpos( $current_uri, $page ) !== false ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get hPanel domain URL
|
||||
public function getHpanelDomainUrl() : string {
|
||||
$parsed_url = parse_url( get_site_url() );
|
||||
$host = $parsed_url['host'];
|
||||
$directory = __DIR__;
|
||||
|
||||
// Remove 'www.' if it exists in the host
|
||||
if ( strpos( $host, 'www.' ) === 0 ) {
|
||||
$host = substr( $host, 4 );
|
||||
}
|
||||
|
||||
// Parse the host into parts
|
||||
$host_parts = explode( '.', $host );
|
||||
$is_subdomain = count( $host_parts ) > 2;
|
||||
|
||||
// Helper to get the base domain (last two parts)
|
||||
$base_domain = implode( '.', array_slice( $host_parts, -2 ) );
|
||||
|
||||
// System folders to ignore
|
||||
$system_folders = [ 'wp-content', 'plugins', 'themes', 'uploads' ];
|
||||
|
||||
// Detect if there is a subdirectory immediately after 'public_html'
|
||||
$subdirectory_name = '';
|
||||
if ( preg_match( '/\/public_html\/([^\/]+)\//', $directory, $matches ) && ! in_array( $matches[1], $system_folders ) ) {
|
||||
$subdirectory_name = $matches[1];
|
||||
}
|
||||
|
||||
// Handle preview domains
|
||||
if ( $this->isPreviewDomain() ) {
|
||||
$host_parts = explode( '.', $host );
|
||||
$base_domain = str_replace( '-', '.', $host_parts[0] );
|
||||
|
||||
return self::HPANEL_DOMAIN_URL . "$base_domain." . end( $host_parts );
|
||||
}
|
||||
|
||||
// Handle subdomain with a directory structure
|
||||
if ( $subdirectory_name !== '' ) {
|
||||
$full_domain = "$subdirectory_name.$base_domain";
|
||||
|
||||
return self::HPANEL_DOMAIN_URL . "$base_domain/wordpress/dashboard/$full_domain";
|
||||
}
|
||||
|
||||
// Handle top-level subdomain (no subdirectory structure)
|
||||
if ( $is_subdomain ) {
|
||||
return self::HPANEL_DOMAIN_URL . "$host";
|
||||
}
|
||||
|
||||
// Default to handling top-level domains (without subdomains)
|
||||
return self::HPANEL_DOMAIN_URL . "$host";
|
||||
}
|
||||
|
||||
// Check transient eligibility
|
||||
public function checkTransientEligibility( $transient_request_key, $cache_time = 3600 ): bool {
|
||||
try {
|
||||
// Set transient
|
||||
set_transient( $transient_request_key, true, $cache_time );
|
||||
|
||||
// Check if transient was set successfully
|
||||
if ( false === get_transient( $transient_request_key ) ) {
|
||||
throw new \Exception( 'Unable to create transient in WordPress.' );
|
||||
}
|
||||
|
||||
// If everything is fine, return true
|
||||
return true;
|
||||
} catch ( \Exception $exception ) {
|
||||
// If there's an exception, log the error and return false
|
||||
$this->errorLog( 'Error checking eligibility: ' . $exception->getMessage() );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function errorLog( string $message ): void {
|
||||
if ( defined( 'WP_DEBUG' ) && \WP_DEBUG === true ) {
|
||||
error_log( print_r( $message, true ) );
|
||||
}
|
||||
}
|
||||
|
||||
public static function getSetting( string $setting ): string {
|
||||
|
||||
if ( $setting ) {
|
||||
return get_option( 'hostinger_' . $setting, '' );
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public static function updateSetting( string $setting, $value, $autoload = null ): void {
|
||||
|
||||
if ( $setting ) {
|
||||
update_option( 'hostinger_' . $setting, $value, $autoload );
|
||||
}
|
||||
}
|
||||
|
||||
public static function flushLitespeedCache(): void {
|
||||
if ( has_action( 'litespeed_purge_all' ) ) {
|
||||
do_action( 'litespeed_purge_all' );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "docker" # See documentation for possible values
|
||||
directories:
|
||||
- "**/*" # Location of package manifests
|
||||
labels:
|
||||
- "dependencies"
|
||||
- "docker"
|
||||
reviewers:
|
||||
- "hostinger/wp-devs"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
@@ -0,0 +1,11 @@
|
||||
name: sca-scan
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [master, main, staging]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
run-sca:
|
||||
uses: hostinger/sca-configs/.github/workflows/sca.yml@main
|
||||
secrets: inherit
|
||||
@@ -0,0 +1,131 @@
|
||||
# WordPress Menu Manager PHP package
|
||||
|
||||
Package for managing Hostinger WordPress menus and pages.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Installation](#installation)
|
||||
- [Usage](#usage)
|
||||
- [Code Testing](#code-testing)
|
||||
- [Translation](#translation)
|
||||
- [Support](#support)
|
||||
|
||||
## Installation
|
||||
|
||||
This is private package, adding it to composer is a bit different.
|
||||
|
||||
Add it to the composer.json:
|
||||
```sh
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "git@github.com:hostinger/hostinger-wp-menu-manager.git"
|
||||
}
|
||||
],
|
||||
```
|
||||
|
||||
and:
|
||||
```sh
|
||||
"require": {
|
||||
"hostinger/hostinger-wp-menu-manager": "dev-main OR dev-branch",
|
||||
}
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
First thing boot up package in main plugin file:
|
||||
|
||||
```sh
|
||||
use Hostinger\WpMenuManager\Manager;
|
||||
|
||||
if( !function_exists('hostinger_load_menus') ) {
|
||||
function hostinger_load_menus(): void {
|
||||
$manager = Manager::getInstance();
|
||||
$manager->boot();
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! has_action( 'plugins_loaded', 'hostinger_load_menus' ) ) {
|
||||
add_action('plugins_loaded', 'hostinger_load_menus');
|
||||
}
|
||||
```
|
||||
|
||||
You are ready to go. There are several hooks for use.
|
||||
|
||||
**hostinger_menu_subpages** - add new subpage under Hostinger menu item
|
||||
|
||||
```sh
|
||||
add_filter('hostinger_menu_subpages', function($submenus) {
|
||||
$example_submenu = array(
|
||||
'page_title' => 'Example Submenu',
|
||||
'menu_title' => 'Example Submenu',
|
||||
'capability' => 'manage_options',
|
||||
'menu_slug' => 'example-submenu',
|
||||
'callback' => [$this, 'test'],
|
||||
'menu_order' => 10
|
||||
);
|
||||
|
||||
$submenus[] = $example_submenu;
|
||||
|
||||
return $submenus;
|
||||
});
|
||||
```
|
||||
|
||||
**hostinger_admin_menu_bar_items** - add new sub menu items under Hostinger admin bar menu
|
||||
|
||||
```sh
|
||||
add_filter('hostinger_admin_menu_bar_items', function($menu_items) {
|
||||
$menu_item = array(
|
||||
'id' => 'billings',
|
||||
'title' => 'Billings',
|
||||
'href' => 'https://',
|
||||
'meta' => [
|
||||
'target' => '_blank'
|
||||
]
|
||||
);
|
||||
|
||||
$menu_items[] = $menu_item;
|
||||
|
||||
return $menu_items;
|
||||
});
|
||||
```
|
||||
|
||||
You also need to render Hostinger navigation inside your pages:
|
||||
|
||||
```sh
|
||||
use Hostinger\WpMenuManager\Menus;
|
||||
|
||||
echo Menus::renderMenuNavigation();
|
||||
```
|
||||
|
||||
If you want to hide all menu items and only show one view you can:
|
||||
|
||||
1) Update **hostinger_hide_subpages** option with true
|
||||
|
||||
2) Hook into **hostinger_main_menu_content**
|
||||
|
||||
```sh
|
||||
add_action('hostinger_main_menu_content', function() {
|
||||
echo 'I am main content';
|
||||
});
|
||||
```
|
||||
|
||||
## Code Testing
|
||||
|
||||
PHP_CodeSniffer package is used to check code against code standards. PSR-12 standard is used.
|
||||
|
||||
```sh
|
||||
$ vendor/bin/phpcs -ps
|
||||
```
|
||||
|
||||
Translation
|
||||
|
||||
## Generate .pot file with this command
|
||||
|
||||
```sh
|
||||
$ wp i18n make-pot src/ languages/hostinger-wp-menu-package.pot --domain=hostinger-wp-menu-package
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
Package initially was written by Daniels Martinovs (daniels.martinovs@hostinger.com). You can ping him in Slack for support.
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
(()=>{var e,r={144:()=>{jQuery(document).on("ready",(function(){window.addEventListener("onboardingMenuToggle",(function(e){var r="hostinger-hide-all-menu-items";switch(e.detail&&e.detail.operation?e.detail.operation:"show"){case"show":document.querySelector("body").classList.remove(r);break;case"hide":document.querySelector("body").classList.add(r)}})),window.addEventListener("resize",(function(){var e=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,r=document.querySelector(".hsr-wrapper__list"),t=document.querySelector(".hsr-mobile-sidebar .hsr-wrapper"),o=document.querySelector(".hsr-navbar-buttons");if(e<=1085)r&&t&&(t.appendChild(r),null!==o&&t.appendChild(o));else{var n=document.querySelector(".hsr-onboarding-navbar__wrapper");r&&n&&(n.appendChild(r),null!==o&&n.appendChild(o),document.querySelector(".hsr-mobile-sidebar").classList.remove("hsr-active"))}})),window.dispatchEvent(new Event("resize"));var e=document.querySelector(".hsr-mobile-sidebar"),r=document.querySelectorAll(".hsr-close, .hsr-mobile-menu-icon");null!==r&&r.forEach((function(r){r.addEventListener("click",(function(r){e.classList.toggle("hsr-active"),document.querySelector("body").classList.toggle("hsr-sidebar-active"),r.stopPropagation()}))})),document.addEventListener("click",(function(r){null!==e&&(e.contains(r.target)||(e.classList.remove("hsr-active"),document.querySelector("body").classList.remove("hsr-sidebar-active")))}))}))},796:()=>{}},t={};function o(e){var n=t[e];if(void 0!==n)return n.exports;var i=t[e]={exports:{}};return r[e](i,i.exports,o),i.exports}o.m=r,e=[],o.O=(r,t,n,i)=>{if(!t){var s=1/0;for(l=0;l<e.length;l++){for(var[t,n,i]=e[l],a=!0,c=0;c<t.length;c++)(!1&i||s>=i)&&Object.keys(o.O).every((e=>o.O[e](t[c])))?t.splice(c--,1):(a=!1,i<s&&(s=i));if(a){e.splice(l--,1);var d=n();void 0!==d&&(r=d)}}return r}i=i||0;for(var l=e.length;l>0&&e[l-1][2]>i;l--)e[l]=e[l-1];e[l]=[t,n,i]},o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{var e={580:0,540:0};o.O.j=r=>0===e[r];var r=(r,t)=>{var n,i,[s,a,c]=t,d=0;if(s.some((r=>0!==e[r]))){for(n in a)o.o(a,n)&&(o.m[n]=a[n]);if(c)var l=c(o)}for(r&&r(t);d<s.length;d++)i=s[d],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return o.O(l)},t=self.webpackChunk=self.webpackChunk||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})(),o.O(void 0,[540],(()=>o(144)));var n=o.O(void 0,[540],(()=>o(796)));n=o.O(n)})();
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "git@github.com:hostinger/hostinger-wp-helper.git"
|
||||
}
|
||||
],
|
||||
"name": "hostinger/hostinger-wp-menu-manager",
|
||||
"description": "Package for managing Hostinger WordPress menus and pages.",
|
||||
"license": "proprietary",
|
||||
"type": "library",
|
||||
"version": "1.2.11",
|
||||
"require": {
|
||||
"hostinger/hostinger-wp-helper": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"squizlabs/php_codesniffer": "^3.0",
|
||||
"phpunit/phpunit": "^9.6",
|
||||
"yoast/phpunit-polyfills": "^2.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Hostinger\\WpMenuManager\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Hostinger\\WpMenuManager\\Tests\\": "tests/phpunit"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,61 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Menu management package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: Arabic\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-04-30T07:45:18+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-14 10:59+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-menu-package\n"
|
||||
"Language: ar\n"
|
||||
"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100 >= 3 "
|
||||
"&& n%100<=10 ? 3 : n%100 >= 11 && n%100<=99 ? 4 : 5;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid "Action Required:"
|
||||
msgstr "الإجراء المطلوب:"
|
||||
|
||||
#: Menus.php:228
|
||||
#, fuzzy
|
||||
msgid "Affected plugins:"
|
||||
msgstr "الإضافات المتأثرة:"
|
||||
|
||||
#: Menus.php:208
|
||||
#, fuzzy
|
||||
msgid "Attention! Outdated Plugins Detected"
|
||||
msgstr "تنبيه! تم اكتشاف ملحقات قديمة"
|
||||
|
||||
#: templates/menu.php:83
|
||||
#, fuzzy
|
||||
msgid "Go to hPanel"
|
||||
msgstr "انتقل إلى hPanel"
|
||||
|
||||
#: Menus.php:58 Menus.php:104 Menus.php:105
|
||||
#, fuzzy
|
||||
msgid "Hostinger"
|
||||
msgstr "هوستنجر"
|
||||
|
||||
#: Menus.php:220
|
||||
#, fuzzy
|
||||
msgid "Outdated plugins:"
|
||||
msgstr "الإضافات القديمة:"
|
||||
|
||||
#: Menus.php:237
|
||||
#, fuzzy
|
||||
msgid "Update plugins"
|
||||
msgstr "تحديث المكونات الإضافية"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
"Your website has some outdated plugins that might prevent new features from "
|
||||
"working properly."
|
||||
msgstr ""
|
||||
"يحتوي موقعك الإلكتروني على بعض الإضافات القديمة التي قد تمنع الميزات الجديدة "
|
||||
"من العمل بشكل صحيح."
|
||||
Binary file not shown.
@@ -0,0 +1,58 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Menu management package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: German\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-04-30T07:45:18+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-14 10:59+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-menu-package\n"
|
||||
"Language: de_DE\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid "Action Required:"
|
||||
msgstr "Aktion erforderlich:"
|
||||
|
||||
#: Menus.php:228
|
||||
#, fuzzy
|
||||
msgid "Affected plugins:"
|
||||
msgstr "Betroffene Plugins:"
|
||||
|
||||
#: Menus.php:208
|
||||
#, fuzzy
|
||||
msgid "Attention! Outdated Plugins Detected"
|
||||
msgstr "Achtung! Veraltete Plugins entdeckt"
|
||||
|
||||
#: templates/menu.php:83
|
||||
msgid "Go to hPanel"
|
||||
msgstr "Zum hPanel gehen"
|
||||
|
||||
#: Menus.php:58 Menus.php:104 Menus.php:105
|
||||
msgid "Hostinger"
|
||||
msgstr "Hostinger"
|
||||
|
||||
#: Menus.php:220
|
||||
#, fuzzy
|
||||
msgid "Outdated plugins:"
|
||||
msgstr "Veraltete Plugins:"
|
||||
|
||||
#: Menus.php:237
|
||||
#, fuzzy
|
||||
msgid "Update plugins"
|
||||
msgstr "Plugins aktualisieren"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
"Your website has some outdated plugins that might prevent new features from "
|
||||
"working properly."
|
||||
msgstr ""
|
||||
"Deine Website hat einige veraltete Plugins, die verhindern können, dass neue "
|
||||
"Funktionen richtig funktionieren."
|
||||
Binary file not shown.
@@ -0,0 +1,58 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Menu management package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: Spanish (Spain)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-04-30T07:45:18+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-14 10:59+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-menu-package\n"
|
||||
"Language: es_ES\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid "Action Required:"
|
||||
msgstr "Acción requerida:"
|
||||
|
||||
#: Menus.php:228
|
||||
#, fuzzy
|
||||
msgid "Affected plugins:"
|
||||
msgstr "Plugins afectados:"
|
||||
|
||||
#: Menus.php:208
|
||||
#, fuzzy
|
||||
msgid "Attention! Outdated Plugins Detected"
|
||||
msgstr "Atención Plugins obsoletos detectados"
|
||||
|
||||
#: templates/menu.php:83
|
||||
msgid "Go to hPanel"
|
||||
msgstr "Ir a hPanel"
|
||||
|
||||
#: Menus.php:58 Menus.php:104 Menus.php:105
|
||||
msgid "Hostinger"
|
||||
msgstr "Hostinger"
|
||||
|
||||
#: Menus.php:220
|
||||
#, fuzzy
|
||||
msgid "Outdated plugins:"
|
||||
msgstr "Plugins obsoletos:"
|
||||
|
||||
#: Menus.php:237
|
||||
#, fuzzy
|
||||
msgid "Update plugins"
|
||||
msgstr "Actualizar plugins"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
"Your website has some outdated plugins that might prevent new features from "
|
||||
"working properly."
|
||||
msgstr ""
|
||||
"Su sitio web tiene algunos plugins obsoletos que podrían impedir que las "
|
||||
"nuevas funciones funcionen correctamente."
|
||||
Binary file not shown.
@@ -0,0 +1,58 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Menu management package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: French (France)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-04-30T07:45:18+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-14 10:59+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-menu-package\n"
|
||||
"Language: fr_FR\n"
|
||||
"Plural-Forms: nplurals=2; plural=n > 1;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid "Action Required:"
|
||||
msgstr "Action requise :"
|
||||
|
||||
#: Menus.php:228
|
||||
#, fuzzy
|
||||
msgid "Affected plugins:"
|
||||
msgstr "Plugins concernés :"
|
||||
|
||||
#: Menus.php:208
|
||||
#, fuzzy
|
||||
msgid "Attention! Outdated Plugins Detected"
|
||||
msgstr "Attention ! Plugins obsolètes détectés"
|
||||
|
||||
#: templates/menu.php:83
|
||||
msgid "Go to hPanel"
|
||||
msgstr "Accédez au hPanel"
|
||||
|
||||
#: Menus.php:58 Menus.php:104 Menus.php:105
|
||||
msgid "Hostinger"
|
||||
msgstr "Hostinger"
|
||||
|
||||
#: Menus.php:220
|
||||
#, fuzzy
|
||||
msgid "Outdated plugins:"
|
||||
msgstr "Plugins obsolètes :"
|
||||
|
||||
#: Menus.php:237
|
||||
#, fuzzy
|
||||
msgid "Update plugins"
|
||||
msgstr "Mise à jour des plugins"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
"Your website has some outdated plugins that might prevent new features from "
|
||||
"working properly."
|
||||
msgstr ""
|
||||
"Votre site web contient des plugins obsolètes qui peuvent empêcher les "
|
||||
"nouvelles fonctionnalités de fonctionner correctement."
|
||||
Binary file not shown.
@@ -0,0 +1,50 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Menu management package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: Hindi\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-04-30T07:45:18+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-14 10:58+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-menu-package\n"
|
||||
"Language: hi_IN\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: Menus.php:211
|
||||
msgid "Action Required:"
|
||||
msgstr ""
|
||||
|
||||
#: Menus.php:228
|
||||
msgid "Affected plugins:"
|
||||
msgstr ""
|
||||
|
||||
#: Menus.php:208
|
||||
msgid "Attention! Outdated Plugins Detected"
|
||||
msgstr ""
|
||||
|
||||
#: templates/menu.php:83
|
||||
msgid "Go to hPanel"
|
||||
msgstr "hPanel पर जाएं"
|
||||
|
||||
#: Menus.php:58 Menus.php:104 Menus.php:105
|
||||
msgid "Hostinger"
|
||||
msgstr "Hostinger"
|
||||
|
||||
#: Menus.php:220
|
||||
msgid "Outdated plugins:"
|
||||
msgstr ""
|
||||
|
||||
#: Menus.php:237
|
||||
msgid "Update plugins"
|
||||
msgstr ""
|
||||
|
||||
#: Menus.php:211
|
||||
msgid ""
|
||||
"Your website has some outdated plugins that might prevent new features from "
|
||||
"working properly."
|
||||
msgstr ""
|
||||
Binary file not shown.
@@ -0,0 +1,58 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Menu management package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: Indonesian\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-04-30T07:45:18+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-14 10:59+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-menu-package\n"
|
||||
"Language: id_ID\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid "Action Required:"
|
||||
msgstr "Tindakan yang diperlukan:"
|
||||
|
||||
#: Menus.php:228
|
||||
#, fuzzy
|
||||
msgid "Affected plugins:"
|
||||
msgstr "Plugin yang terpengaruh:"
|
||||
|
||||
#: Menus.php:208
|
||||
#, fuzzy
|
||||
msgid "Attention! Outdated Plugins Detected"
|
||||
msgstr "Perhatian! Plugin Kedaluwarsa Terdeteksi"
|
||||
|
||||
#: templates/menu.php:83
|
||||
msgid "Go to hPanel"
|
||||
msgstr "Buka hPanel"
|
||||
|
||||
#: Menus.php:58 Menus.php:104 Menus.php:105
|
||||
msgid "Hostinger"
|
||||
msgstr "Hostinger"
|
||||
|
||||
#: Menus.php:220
|
||||
#, fuzzy
|
||||
msgid "Outdated plugins:"
|
||||
msgstr "Plugin yang sudah ketinggalan zaman:"
|
||||
|
||||
#: Menus.php:237
|
||||
#, fuzzy
|
||||
msgid "Update plugins"
|
||||
msgstr "Perbarui plugin"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
"Your website has some outdated plugins that might prevent new features from "
|
||||
"working properly."
|
||||
msgstr ""
|
||||
"Situs web Anda memiliki beberapa plugin usang yang mungkin menghalangi fitur-"
|
||||
"fitur baru untuk bekerja dengan baik."
|
||||
Binary file not shown.
@@ -0,0 +1,58 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Menu management package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: Italian\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-04-30T07:45:18+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-14 10:58+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-menu-package\n"
|
||||
"Language: it_IT\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid "Action Required:"
|
||||
msgstr "Azione richiesta:"
|
||||
|
||||
#: Menus.php:228
|
||||
#, fuzzy
|
||||
msgid "Affected plugins:"
|
||||
msgstr "Plugin interessati:"
|
||||
|
||||
#: Menus.php:208
|
||||
#, fuzzy
|
||||
msgid "Attention! Outdated Plugins Detected"
|
||||
msgstr "Attenzione! Rilevati plugin obsoleti"
|
||||
|
||||
#: templates/menu.php:83
|
||||
msgid "Go to hPanel"
|
||||
msgstr "Vai su hPanel"
|
||||
|
||||
#: Menus.php:58 Menus.php:104 Menus.php:105
|
||||
msgid "Hostinger"
|
||||
msgstr "Hostinger"
|
||||
|
||||
#: Menus.php:220
|
||||
#, fuzzy
|
||||
msgid "Outdated plugins:"
|
||||
msgstr "Plugin obsoleti:"
|
||||
|
||||
#: Menus.php:237
|
||||
#, fuzzy
|
||||
msgid "Update plugins"
|
||||
msgstr "Aggiornare i plugin"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
"Your website has some outdated plugins that might prevent new features from "
|
||||
"working properly."
|
||||
msgstr ""
|
||||
"Il vostro sito web ha alcuni plugin obsoleti che potrebbero impedire il "
|
||||
"corretto funzionamento di nuove funzionalità."
|
||||
Binary file not shown.
@@ -0,0 +1,59 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Menu management package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: Gabriele Motuzaite\n"
|
||||
"Language-Team: Lithuanian\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-04-30T07:45:18+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-14 10:59+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-menu-package\n"
|
||||
"Language: lt_LT\n"
|
||||
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10 >= 2 "
|
||||
"&&(n%100<10||n%100 >= 20)? 1 : 2);\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid "Action Required:"
|
||||
msgstr "Reikalingi veiksmai:"
|
||||
|
||||
#: Menus.php:228
|
||||
#, fuzzy
|
||||
msgid "Affected plugins:"
|
||||
msgstr "Paveikti įskiepiai:"
|
||||
|
||||
#: Menus.php:208
|
||||
#, fuzzy
|
||||
msgid "Attention! Outdated Plugins Detected"
|
||||
msgstr "Dėmesio! Aptikti pasenę įskiepiai"
|
||||
|
||||
#: templates/menu.php:83
|
||||
msgid "Go to hPanel"
|
||||
msgstr "Eiti į hPanel"
|
||||
|
||||
#: Menus.php:58 Menus.php:104 Menus.php:105
|
||||
msgid "Hostinger"
|
||||
msgstr "Hostinger"
|
||||
|
||||
#: Menus.php:220
|
||||
#, fuzzy
|
||||
msgid "Outdated plugins:"
|
||||
msgstr "Pasenę įskiepiai:"
|
||||
|
||||
#: Menus.php:237
|
||||
#, fuzzy
|
||||
msgid "Update plugins"
|
||||
msgstr "Atnaujinti įskiepius"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
"Your website has some outdated plugins that might prevent new features from "
|
||||
"working properly."
|
||||
msgstr ""
|
||||
"Jūsų svetainėje yra pasenusių įskiepių, kurie gali trukdyti tinkamai veikti "
|
||||
"naujoms funkcijoms."
|
||||
Binary file not shown.
@@ -0,0 +1,58 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Menu management package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: Dutch\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-04-30T07:45:18+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-14 10:58+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-menu-package\n"
|
||||
"Language: nl_NL\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid "Action Required:"
|
||||
msgstr "Vereiste actie:"
|
||||
|
||||
#: Menus.php:228
|
||||
#, fuzzy
|
||||
msgid "Affected plugins:"
|
||||
msgstr "Betreffende plugins:"
|
||||
|
||||
#: Menus.php:208
|
||||
#, fuzzy
|
||||
msgid "Attention! Outdated Plugins Detected"
|
||||
msgstr "Attentie! Verouderde plugins gedetecteerd"
|
||||
|
||||
#: templates/menu.php:83
|
||||
msgid "Go to hPanel"
|
||||
msgstr "Ga naar hPanel"
|
||||
|
||||
#: Menus.php:58 Menus.php:104 Menus.php:105
|
||||
msgid "Hostinger"
|
||||
msgstr "Hostinger"
|
||||
|
||||
#: Menus.php:220
|
||||
#, fuzzy
|
||||
msgid "Outdated plugins:"
|
||||
msgstr "Verouderde plugins:"
|
||||
|
||||
#: Menus.php:237
|
||||
#, fuzzy
|
||||
msgid "Update plugins"
|
||||
msgstr "Plugins bijwerken"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
"Your website has some outdated plugins that might prevent new features from "
|
||||
"working properly."
|
||||
msgstr ""
|
||||
"Je website heeft een aantal verouderde plugins waardoor nieuwe functies "
|
||||
"mogelijk niet goed werken."
|
||||
Binary file not shown.
@@ -0,0 +1,58 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Menu management package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: Portuguese (Brazil)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-04-30T07:45:18+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-14 10:57+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-menu-package\n"
|
||||
"Language: pt_BR\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid "Action Required:"
|
||||
msgstr "Ação necessária:"
|
||||
|
||||
#: Menus.php:228
|
||||
#, fuzzy
|
||||
msgid "Affected plugins:"
|
||||
msgstr "Plugins afetados:"
|
||||
|
||||
#: Menus.php:208
|
||||
#, fuzzy
|
||||
msgid "Attention! Outdated Plugins Detected"
|
||||
msgstr "Atenção! Detectados plug-ins desatualizados"
|
||||
|
||||
#: templates/menu.php:83
|
||||
msgid "Go to hPanel"
|
||||
msgstr "Ir para o hPanel"
|
||||
|
||||
#: Menus.php:58 Menus.php:104 Menus.php:105
|
||||
msgid "Hostinger"
|
||||
msgstr "Hostinger"
|
||||
|
||||
#: Menus.php:220
|
||||
#, fuzzy
|
||||
msgid "Outdated plugins:"
|
||||
msgstr "Plugins desatualizados:"
|
||||
|
||||
#: Menus.php:237
|
||||
#, fuzzy
|
||||
msgid "Update plugins"
|
||||
msgstr "Atualizar plug-ins"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
"Your website has some outdated plugins that might prevent new features from "
|
||||
"working properly."
|
||||
msgstr ""
|
||||
"Seu site tem alguns plug-ins desatualizados que podem impedir que novos "
|
||||
"recursos funcionem corretamente."
|
||||
Binary file not shown.
@@ -0,0 +1,58 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Menu management package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: Portuguese (Portugal)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-04-30T07:45:18+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-14 11:00+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-menu-package\n"
|
||||
"Language: pt_PT\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid "Action Required:"
|
||||
msgstr "Ação necessária:"
|
||||
|
||||
#: Menus.php:228
|
||||
#, fuzzy
|
||||
msgid "Affected plugins:"
|
||||
msgstr "Plugins afectados:"
|
||||
|
||||
#: Menus.php:208
|
||||
#, fuzzy
|
||||
msgid "Attention! Outdated Plugins Detected"
|
||||
msgstr "Atenção! Detectados plugins desactualizados"
|
||||
|
||||
#: templates/menu.php:83
|
||||
msgid "Go to hPanel"
|
||||
msgstr "Aceder ao hPanel"
|
||||
|
||||
#: Menus.php:58 Menus.php:104 Menus.php:105
|
||||
msgid "Hostinger"
|
||||
msgstr "Hostinger"
|
||||
|
||||
#: Menus.php:220
|
||||
#, fuzzy
|
||||
msgid "Outdated plugins:"
|
||||
msgstr "Plugins desactualizados:"
|
||||
|
||||
#: Menus.php:237
|
||||
#, fuzzy
|
||||
msgid "Update plugins"
|
||||
msgstr "Atualizar plugins"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
"Your website has some outdated plugins that might prevent new features from "
|
||||
"working properly."
|
||||
msgstr ""
|
||||
"O seu sítio Web tem alguns plug-ins desactualizados que podem impedir que as "
|
||||
"novas funcionalidades funcionem corretamente."
|
||||
Binary file not shown.
@@ -0,0 +1,58 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Menu management package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: Turkish\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-04-30T07:45:18+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-14 11:00+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-menu-package\n"
|
||||
"Language: tr_TR\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid "Action Required:"
|
||||
msgstr "Yapılması Gerekenler:"
|
||||
|
||||
#: Menus.php:228
|
||||
#, fuzzy
|
||||
msgid "Affected plugins:"
|
||||
msgstr "Etkilenen eklentiler:"
|
||||
|
||||
#: Menus.php:208
|
||||
#, fuzzy
|
||||
msgid "Attention! Outdated Plugins Detected"
|
||||
msgstr "Dikkat! Güncel Olmayan Eklentiler Tespit Edildi"
|
||||
|
||||
#: templates/menu.php:83
|
||||
msgid "Go to hPanel"
|
||||
msgstr "HPanel'e git"
|
||||
|
||||
#: Menus.php:58 Menus.php:104 Menus.php:105
|
||||
msgid "Hostinger"
|
||||
msgstr "Hostinger"
|
||||
|
||||
#: Menus.php:220
|
||||
#, fuzzy
|
||||
msgid "Outdated plugins:"
|
||||
msgstr "Eski eklentiler:"
|
||||
|
||||
#: Menus.php:237
|
||||
#, fuzzy
|
||||
msgid "Update plugins"
|
||||
msgstr "Eklentileri güncelleyin"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
"Your website has some outdated plugins that might prevent new features from "
|
||||
"working properly."
|
||||
msgstr ""
|
||||
"Web sitenizde yeni özelliklerin düzgün çalışmasını engelleyebilecek bazı "
|
||||
"eski eklentiler var."
|
||||
Binary file not shown.
@@ -0,0 +1,59 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Menu management package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: Julia\n"
|
||||
"Language-Team: Ukrainian\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-04-30T07:45:18+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-14 10:58+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-menu-package\n"
|
||||
"Language: uk\n"
|
||||
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10 >= 2 && "
|
||||
"n%10<=4 &&(n%100<10||n%100 >= 20)? 1 : 2);\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid "Action Required:"
|
||||
msgstr "Потрібні дії:"
|
||||
|
||||
#: Menus.php:228
|
||||
#, fuzzy
|
||||
msgid "Affected plugins:"
|
||||
msgstr "Постраждалі плагіни:"
|
||||
|
||||
#: Menus.php:208
|
||||
#, fuzzy
|
||||
msgid "Attention! Outdated Plugins Detected"
|
||||
msgstr "Увага! Виявлено застарілі плагіни"
|
||||
|
||||
#: templates/menu.php:83
|
||||
msgid "Go to hPanel"
|
||||
msgstr "Перейти до hPanel"
|
||||
|
||||
#: Menus.php:58 Menus.php:104 Menus.php:105
|
||||
msgid "Hostinger"
|
||||
msgstr "Hostinger"
|
||||
|
||||
#: Menus.php:220
|
||||
#, fuzzy
|
||||
msgid "Outdated plugins:"
|
||||
msgstr "Застарілі плагіни:"
|
||||
|
||||
#: Menus.php:237
|
||||
#, fuzzy
|
||||
msgid "Update plugins"
|
||||
msgstr "Оновлення плагінів"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
"Your website has some outdated plugins that might prevent new features from "
|
||||
"working properly."
|
||||
msgstr ""
|
||||
"На вашому веб-сайті встановлені застарілі плагіни, які можуть перешкоджати "
|
||||
"належній роботі нових функцій."
|
||||
Binary file not shown.
@@ -0,0 +1,56 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Menu management package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: Zhou Yu\n"
|
||||
"Language-Team: Chinese (China)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-04-30T07:45:18+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-14 11:00+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-menu-package\n"
|
||||
"Language: zh_CN\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid "Action Required:"
|
||||
msgstr "需要采取的行动:"
|
||||
|
||||
#: Menus.php:228
|
||||
#, fuzzy
|
||||
msgid "Affected plugins:"
|
||||
msgstr "受影响的插件:"
|
||||
|
||||
#: Menus.php:208
|
||||
#, fuzzy
|
||||
msgid "Attention! Outdated Plugins Detected"
|
||||
msgstr "请注意!检测到过期插件"
|
||||
|
||||
#: templates/menu.php:83
|
||||
msgid "Go to hPanel"
|
||||
msgstr "转到 hPanel "
|
||||
|
||||
#: Menus.php:58 Menus.php:104 Menus.php:105
|
||||
msgid "Hostinger"
|
||||
msgstr "Hostinger"
|
||||
|
||||
#: Menus.php:220
|
||||
#, fuzzy
|
||||
msgid "Outdated plugins:"
|
||||
msgstr "过时的插件:"
|
||||
|
||||
#: Menus.php:237
|
||||
#, fuzzy
|
||||
msgid "Update plugins"
|
||||
msgstr "更新插件"
|
||||
|
||||
#: Menus.php:211
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
"Your website has some outdated plugins that might prevent new features from "
|
||||
"working properly."
|
||||
msgstr "您的网站有一些过时的插件,可能会妨碍新功能的正常运行。"
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
namespace Hostinger\WpMenuManager;
|
||||
|
||||
use Hostinger\WpMenuManager\Menus;
|
||||
use Hostinger\WpHelper\Utils;
|
||||
|
||||
class Assets
|
||||
{
|
||||
/**
|
||||
* @var Manager
|
||||
*/
|
||||
private Manager $manager;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
if (!$this->manager->checkCompatibility()) {
|
||||
add_action('admin_enqueue_scripts', [$this, 'enqueueAdminAssets']);
|
||||
add_action('admin_head', [$this, 'addMenuHidingCss']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Manager $manager
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setManager(Manager $manager): void
|
||||
{
|
||||
$this->manager = $manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function enqueueAdminAssets(): void
|
||||
{
|
||||
if ($this->isHostingerMenuPage()) {
|
||||
wp_enqueue_script(
|
||||
'hostinger_menu_scripts',
|
||||
$this->manager->getPluginInfo() . '/vendor/hostinger/hostinger-wp-menu-manager/assets/js/menus.min.js',
|
||||
[
|
||||
'jquery',
|
||||
],
|
||||
'1.1.4',
|
||||
false
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'hostinger_menu_styles',
|
||||
$this->manager->getPluginInfo()
|
||||
. '/vendor/hostinger/hostinger-wp-menu-manager/assets/css/style.min.css',
|
||||
[],
|
||||
'1.1.4'
|
||||
);
|
||||
|
||||
//Hide notices and badges in Hostinger menu pages.
|
||||
$hide_notices = '.notice { display: none !important; } .hostinger-notice { display: block !important; }';
|
||||
wp_add_inline_style('hostinger_menu_styles', $hide_notices);
|
||||
|
||||
if (Utils::isPluginActive('wpforms')) {
|
||||
$hide_wp_forms_counter = '.wp-admin #wpadminbar .wpforms-menu-notification-counter { display: none !important; }';
|
||||
wp_add_inline_style('hostinger_menu_styles', $hide_wp_forms_counter);
|
||||
}
|
||||
if (Utils::isPluginActive('googleanalytics')) {
|
||||
$hide_monsterinsights_notification = '.wp-admin .monsterinsights-menu-notification-indicator { display: none !important; }';
|
||||
wp_add_inline_style('hostinger_menu_styles', $hide_monsterinsights_notification);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function addMenuHidingCss(): void
|
||||
{
|
||||
// These CSS rules should be loaded on every page in WordPress admin.
|
||||
?>
|
||||
<style type="text/css">
|
||||
body.hostinger-hide-main-menu-item #toplevel_page_hostinger .wp-submenu > .wp-first-item {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#wpadminbar #wp-admin-bar-hostinger_admin_bar .ab-item {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
#wpadminbar #wp-admin-bar-hostinger_admin_bar .ab-sub-wrapper .ab-item svg {
|
||||
fill: #9ca1a7;
|
||||
margin-left: 3px;
|
||||
max-height: 18px;
|
||||
}
|
||||
|
||||
body.hostinger-hide-all-menu-items #toplevel_page_hostinger .wp-submenu {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
body.hostinger-hide-all-menu-items .hsr-onboarding-navbar__wrapper {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
body.hostinger-hide-all-menu-items .hsr-onboarding-navbar .hsr-mobile-menu-icon,
|
||||
body.hostinger-hide-all-menu-items .hsr-onboarding-navbar .hsr-wrapper__list {
|
||||
display: none !important;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function isHostingerMenuPage(): bool
|
||||
{
|
||||
$pages = [
|
||||
'wp-admin/admin.php?page=' . Menus::MENU_SLUG
|
||||
];
|
||||
|
||||
$subpages = Menus::getMenuSubpages();
|
||||
|
||||
foreach ($subpages as $page) {
|
||||
if (isset($page['menu_slug'])) {
|
||||
$pages[] = 'wp-admin/admin.php?page=' . $page['menu_slug'];
|
||||
}
|
||||
}
|
||||
|
||||
$utils = new Utils();
|
||||
|
||||
foreach ($pages as $page) {
|
||||
if ($utils->isThisPage($page)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
<?php
|
||||
|
||||
namespace Hostinger\WpMenuManager;
|
||||
|
||||
class Manager
|
||||
{
|
||||
/**
|
||||
* @var Manager instance.
|
||||
*/
|
||||
private static ?Manager $instance = null;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private array $objects = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public array $old_plugins = [
|
||||
[
|
||||
'name' => 'Hostinger',
|
||||
'slug' => 'hostinger',
|
||||
'version' => '3.0.0',
|
||||
],
|
||||
[
|
||||
'name' => 'Hostinger Affiliate Plugin',
|
||||
'slug' => 'hostinger-affiliate-plugin',
|
||||
'version' => '2.0.0',
|
||||
],
|
||||
[
|
||||
'name' => 'Hostinger AI Assistant',
|
||||
'slug' => 'hostinger-ai-assistant',
|
||||
'version' => '2.0.0',
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public array $outdated_plugins = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public array $affected_plugins = [
|
||||
'hostinger' => 'Hostinger Tools',
|
||||
'hostinger-affiliate-plugin' => 'Hostinger Affiliate Connector',
|
||||
'hostinger-ai-assistant' => 'Hostinger AI',
|
||||
'hostinger-easy-onboarding' => 'Hostinger Easy Onboarding',
|
||||
];
|
||||
|
||||
/**
|
||||
* Allow only one instance of class
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function getInstance(): self
|
||||
{
|
||||
if (null === self::$instance) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|string[]
|
||||
*/
|
||||
public function getOutdatedPlugins(): array
|
||||
{
|
||||
return $this->outdated_plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getAffectedActivePlugins(): array
|
||||
{
|
||||
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
||||
|
||||
$plugins = [];
|
||||
|
||||
if (empty($this->getAffectedPlugins())) {
|
||||
return [];
|
||||
}
|
||||
|
||||
foreach ($this->getAffectedPlugins() as $plugin_slug => $plugin_name) {
|
||||
if (\is_plugin_active($plugin_slug . DIRECTORY_SEPARATOR . $plugin_slug . '.php')) {
|
||||
$plugins[$plugin_slug] = $plugin_name;
|
||||
}
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|string[]
|
||||
*/
|
||||
public function getAffectedPlugins(): array
|
||||
{
|
||||
return $this->affected_plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function boot(): bool
|
||||
{
|
||||
// Locale.
|
||||
$this->loadTextDomain();
|
||||
|
||||
// Modules.
|
||||
$this->registerModules();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function registerModules(): void
|
||||
{
|
||||
// Assets.
|
||||
$this->objects['assets'] = new Assets();
|
||||
|
||||
// Menus.
|
||||
$this->objects['menus'] = new Menus();
|
||||
|
||||
$this->addContainer();
|
||||
|
||||
// Init after container is added.
|
||||
$this->objects['assets']->init();
|
||||
$this->objects['menus']->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function addContainer(): bool
|
||||
{
|
||||
if (empty($this->objects)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($this->objects as $object) {
|
||||
if (property_exists($object, 'manager')) {
|
||||
$object->setManager($this);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPluginInfo(): string
|
||||
{
|
||||
$plugin_url = '';
|
||||
|
||||
$plugins = get_plugins();
|
||||
foreach ($plugins as $plugin_path => $plugin_info) {
|
||||
if (str_contains(__FILE__, 'plugins/' . dirname($plugin_path) . '/')) {
|
||||
$plugin_dir = dirname($plugin_path);
|
||||
|
||||
return plugins_url($plugin_dir);
|
||||
}
|
||||
}
|
||||
|
||||
return $plugin_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function loadTextDomain(): void
|
||||
{
|
||||
load_plugin_textdomain(
|
||||
'hostinger-wp-menu-package',
|
||||
false,
|
||||
dirname(dirname(plugin_basename(__FILE__))) . '/languages/'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkCompatibility(): bool
|
||||
{
|
||||
$outdated_plugins = false;
|
||||
|
||||
if (empty($this->old_plugins)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($this->old_plugins as $plugin_data) {
|
||||
if ($this->checkOutdatedPluginVersion($plugin_data['slug'], $plugin_data['version'])) {
|
||||
$outdated_plugins = true;
|
||||
$this->outdated_plugins[$plugin_data['slug']] = $plugin_data['name'];
|
||||
}
|
||||
}
|
||||
|
||||
return $outdated_plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* If main hostinger plugin is outdated
|
||||
*
|
||||
* @return false
|
||||
*/
|
||||
public function maybeDoCompatibilityRedirect(): bool
|
||||
{
|
||||
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
||||
|
||||
$plugin_name = 'hostinger';
|
||||
$current_uri = !empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
|
||||
|
||||
$plugin = current(array_filter($this->old_plugins, fn($p) => $p['slug'] === $plugin_name));
|
||||
|
||||
if (str_contains($current_uri, '/wp-admin/admin.php?page=hostinger')) {
|
||||
if (!$this->checkOutdatedPluginVersion($plugin['slug'], $plugin['version'])) {
|
||||
wp_redirect(get_admin_url());
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $plugin_name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getPluginVersion($plugin_name): string
|
||||
{
|
||||
$version = get_file_data(WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $plugin_name . DIRECTORY_SEPARATOR . $plugin_name . '.php', array('Version'), 'plugin');
|
||||
|
||||
if (empty($version[0])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $version[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $plugin_name
|
||||
* @param $compare_version
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function checkOutdatedPluginVersion($plugin_name, $compare_version): bool
|
||||
{
|
||||
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
||||
|
||||
if (!\is_plugin_active($plugin_name . DIRECTORY_SEPARATOR . $plugin_name . '.php')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$version = $this->getPluginVersion($plugin_name);
|
||||
|
||||
if (empty($version)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return version_compare($version, $compare_version, '<');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,256 @@
|
||||
<?php
|
||||
|
||||
namespace Hostinger\WpMenuManager;
|
||||
|
||||
use WP_Admin_Bar;
|
||||
|
||||
class Menus
|
||||
{
|
||||
/**
|
||||
* @var Manager
|
||||
*/
|
||||
private Manager $manager;
|
||||
|
||||
public const MENU_SLUG = 'hostinger';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
if (!$this->manager->checkCompatibility()) {
|
||||
add_action('admin_bar_menu', [$this, 'modifyAdminBar'], 999);
|
||||
add_filter('admin_body_class', [$this, 'addMenuClass']);
|
||||
add_action('admin_menu', [$this, 'registerAdminMenu']);
|
||||
} else {
|
||||
$this->manager->maybeDoCompatibilityRedirect();
|
||||
add_action('admin_notices', [$this, 'compatibilityMessage'], 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Manager $manager
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setManager(Manager $manager): void
|
||||
{
|
||||
$this->manager = $manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WP_Admin_Bar $bar
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function modifyAdminBar(WP_Admin_Bar $bar): void
|
||||
{
|
||||
if (!is_user_logged_in()){
|
||||
return;
|
||||
}
|
||||
|
||||
$menu_items = apply_filters('hostinger_admin_menu_bar_items', []);
|
||||
|
||||
if (!empty($menu_items)) {
|
||||
$hostinger_icon = '<svg width="28" height="29" viewBox="0 0 28 29" fill="#9ca1a7" style="margin-right: 6px; max-height: 22px; float: left; margin-top: 4px;" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M1.8669 13.6096V0.500465L8.48322 4.02842V9.93472L17.2419 9.93895L23.9655 13.6096H1.8669ZM19.033 8.85388V0.5L25.8277 3.94018V12.801L19.033 8.85388ZM19.033 24.8765V19.0211L10.2067 19.015C10.215 19.054 3.37149 15.2857 3.37149 15.2857L25.8277 15.3911V28.5L19.033 24.8765ZM1.86667 24.8765L1.8669 16.31L8.48322 20.1637V28.3164L1.86667 24.8765Z" fill="" />
|
||||
</svg>';
|
||||
|
||||
$bar->add_menu([
|
||||
'id' => 'hostinger_admin_bar',
|
||||
'parent' => null,
|
||||
'group' => null,
|
||||
'title' => $hostinger_icon . esc_html__('Hostinger', 'hostinger-wp-menu-package'),
|
||||
]);
|
||||
|
||||
foreach ($menu_items as $menu_item) {
|
||||
$menu_item_data = [
|
||||
'id' => $menu_item['id'],
|
||||
'parent' => 'hostinger_admin_bar',
|
||||
'group' => null,
|
||||
'title' => $menu_item['title'],
|
||||
'href' => $menu_item['href'],
|
||||
];
|
||||
|
||||
if( isset( $menu_item['meta'] ) ){
|
||||
$menu_item_data['meta'] = $menu_item['meta'];
|
||||
}
|
||||
|
||||
$bar->add_menu($menu_item_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $classes
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function addMenuClass(mixed $classes): mixed
|
||||
{
|
||||
|
||||
if (!is_string( $classes)) return $classes;
|
||||
|
||||
$classes .= ' hostinger-hide-main-menu-item';
|
||||
|
||||
if (!empty(self::isSubmenuItemsHidden())) {
|
||||
$classes .= ' hostinger-hide-all-menu-items';
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function registerAdminMenu(): bool
|
||||
{
|
||||
$submenus = self::getMenuSubpages();
|
||||
|
||||
if (empty($submenus)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$icon = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyMSAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0wLjAwMDE5OTY1MyAxMS4yMzY4VjAuMDAwMzk4MjM1TDUuNjcxMzMgMy4wMjQzNlY4LjA4NjkxTDEzLjE3ODggOC4wOTA1M0wxOC45NDE5IDExLjIzNjhIMC4wMDAxOTk2NTNaTTE0LjcxNCA3LjE2MDQ3VjBMMjAuNTM4IDIuOTQ4NzJWMTAuNTQzN0wxNC43MTQgNy4xNjA0N1pNMTQuNzE0IDIwLjg5NDJWMTUuODc1M0w3LjE0ODYyIDE1Ljg3QzcuMTU1NjggMTUuOTAzNCAxLjI4OTg0IDEyLjY3MzUgMS4yODk4NCAxMi42NzM1TDIwLjUzOCAxMi43NjM4VjI0TDE0LjcxNCAyMC44OTQyWk0wIDIwLjg5NDFMMC4wMDAyMDE3NjkgMTMuNTUxNEw1LjY3MTMzIDE2Ljg1NDZWMjMuODQyN0wwIDIwLjg5NDFaIiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K';
|
||||
|
||||
add_menu_page(
|
||||
__('Hostinger', 'hostinger-wp-menu-package'),
|
||||
__('Hostinger', 'hostinger-wp-menu-package'),
|
||||
'edit_posts',
|
||||
self::MENU_SLUG,
|
||||
[$this, 'render'],
|
||||
$icon,
|
||||
1
|
||||
);
|
||||
|
||||
$this->registerSubMenus();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function render(): void
|
||||
{
|
||||
if ($this->hasLoadedMainContent() && !empty(self::isSubmenuItemsHidden())) {
|
||||
do_action('hostinger_main_menu_content');
|
||||
} else {
|
||||
$submenus = self::getMenuSubpages();
|
||||
|
||||
if (!empty($submenus)) {
|
||||
call_user_func($submenus[0]['callback']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function renderMenuNavigation(): string
|
||||
{
|
||||
ob_start();
|
||||
|
||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'menu.php';
|
||||
|
||||
$content = ob_get_contents();
|
||||
|
||||
ob_end_clean();
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getMenuSubpages(): array
|
||||
{
|
||||
return apply_filters('hostinger_menu_subpages', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSubmenuItemsHidden(): bool
|
||||
{
|
||||
return !empty(get_option('hostinger_hide_subpages'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function hasLoadedMainContent(): bool
|
||||
{
|
||||
return has_action('hostinger_main_menu_content');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function registerSubMenus(): bool
|
||||
{
|
||||
$submenus = self::getMenuSubpages();
|
||||
|
||||
if (empty($submenus)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($submenus as $submenu) {
|
||||
add_submenu_page(
|
||||
self::MENU_SLUG,
|
||||
$submenu['page_title'],
|
||||
$submenu['menu_title'],
|
||||
$submenu['capability'],
|
||||
$submenu['menu_slug'],
|
||||
$submenu['callback'],
|
||||
$submenu['menu_order']
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function compatibilityMessage(): void
|
||||
{
|
||||
?>
|
||||
<div class="notice notice-error is-dismissible hts-theme-settings">
|
||||
<p>
|
||||
<strong><?php echo __('Attention! Outdated Plugins Detected', 'hostinger-wp-menu-package') ?></strong>
|
||||
</p>
|
||||
<p>
|
||||
<strong><?php echo __('Action Required:', 'hostinger-wp-menu-package') ?></strong> <?php echo __('Your website has some outdated plugins that might prevent new features from working properly.', 'hostinger-wp-menu-package') ?>
|
||||
</p>
|
||||
|
||||
<ul style="list-style: circle;margin-left: 18px;">
|
||||
<?php
|
||||
|
||||
if (!empty($this->manager->getOutdatedPlugins())) {
|
||||
?>
|
||||
<li>
|
||||
<p><?php echo __('Outdated plugins:', 'hostinger-wp-menu-package') ?> <?php echo implode(', ', $this->manager->getOutdatedPlugins()); ?></p>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
if (!empty($this->manager->getAffectedActivePlugins())) {
|
||||
?>
|
||||
<li>
|
||||
<p><?php echo __('Affected plugins:', 'hostinger-wp-menu-package') ?> <?php echo implode(', ', $this->manager->getAffectedActivePlugins()); ?></p>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
?>
|
||||
</ul>
|
||||
<p>
|
||||
<a href="/wp-admin/update-core.php" class="button-primary">
|
||||
<?php echo __('Update plugins', 'hostinger-wp-menu-package') ?>
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
use Hostinger\WpHelper\Utils;
|
||||
|
||||
$submenus = self::getMenuSubpages();
|
||||
|
||||
?>
|
||||
<div class="hsr-overlay"></div>
|
||||
<div class="hsr-onboarding-navbar">
|
||||
<div class="hsr-mobile-sidebar">
|
||||
<div class="hsr-close">
|
||||
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M6.99961 8.04961L1.74961 13.2996C1.59961 13.4496 1.42461 13.5246 1.22461 13.5246C1.02461 13.5246 0.849609 13.4496 0.699609 13.2996C0.549609 13.1496 0.474609 12.9746 0.474609 12.7746C0.474609 12.5746 0.549609 12.3996 0.699609 12.2496L5.94961 6.99961L0.699609 1.74961C0.549609 1.59961 0.474609 1.42461 0.474609 1.22461C0.474609 1.02461 0.549609 0.849609 0.699609 0.699609C0.849609 0.549609 1.02461 0.474609 1.22461 0.474609C1.42461 0.474609 1.59961 0.549609 1.74961 0.699609L6.99961 5.94961L12.2496 0.699609C12.3996 0.549609 12.5746 0.474609 12.7746 0.474609C12.9746 0.474609 13.1496 0.549609 13.2996 0.699609C13.4496 0.849609 13.5246 1.02461 13.5246 1.22461C13.5246 1.42461 13.4496 1.59961 13.2996 1.74961L8.04961 6.99961L13.2996 12.2496C13.4496 12.3996 13.5246 12.5746 13.5246 12.7746C13.5246 12.9746 13.4496 13.1496 13.2996 13.2996C13.1496 13.4496 12.9746 13.5246 12.7746 13.5246C12.5746 13.5246 12.3996 13.4496 12.2496 13.2996L6.99961 8.04961Z"
|
||||
fill="#673DE6"></path>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="hsr-wrapper"></div>
|
||||
</div>
|
||||
<div class="hsr-onboarding-navbar__wrapper">
|
||||
<div class="hsr-logo">
|
||||
<svg class="hsr-mobile-logo" width="24" height="24" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M2.00025 14.046V0.000497794L9.08916 3.78046V10.1086L18.4735 10.1132L25.6774 14.046H2.00025ZM20.3925 8.95058V0L27.6725 3.6859V13.1797L20.3925 8.95058ZM20.3924 26.1177V19.8441L10.9358 19.8375C10.9446 19.8793 3.6123 15.8418 3.6123 15.8418L27.6725 15.9547V30L20.3924 26.1177ZM2 26.1177L2.00025 16.9393L9.08916 21.0683V29.8033L2 26.1177Z" fill="#1D1E20"/>
|
||||
</svg>
|
||||
<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M2.00025 14.046V0.000497794L9.08916 3.78046V10.1086L18.4735 10.1132L25.6774 14.046H2.00025ZM20.3925 8.95058V0L27.6725 3.6859V13.1797L20.3925 8.95058ZM20.3924 26.1177V19.8441L10.9358 19.8375C10.9446 19.8793 3.6123 15.8418 3.6123 15.8418L27.6725 15.9547V30L20.3924 26.1177ZM2 26.1177L2.00025 16.9393L9.08916 21.0683V29.8033L2 26.1177Z" fill="#1D1E20"/>
|
||||
</svg>
|
||||
</div>
|
||||
<svg class="hsr-mobile-menu-icon" width="24" height="24" viewBox="0 0 24 24" fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M3.75 18C3.5375 18 3.35938 17.9277 3.21563 17.7831C3.07187 17.6385 3 17.4594 3 17.2456C3 17.0319 3.07187 16.8542 3.21563 16.7125C3.35938 16.5708 3.5375 16.5 3.75 16.5H20.25C20.4625 16.5 20.6406 16.5723 20.7844 16.7169C20.9281 16.8615 21 17.0406 21 17.2544C21 17.4681 20.9281 17.6458 20.7844 17.7875C20.6406 17.9292 20.4625 18 20.25 18H3.75ZM3.75 12.75C3.5375 12.75 3.35938 12.6777 3.21563 12.5331C3.07187 12.3885 3 12.2094 3 11.9956C3 11.7819 3.07187 11.6042 3.21563 11.4625C3.35938 11.3208 3.5375 11.25 3.75 11.25H20.25C20.4625 11.25 20.6406 11.3223 20.7844 11.4669C20.9281 11.6115 21 11.7906 21 12.0044C21 12.2181 20.9281 12.3958 20.7844 12.5375C20.6406 12.6792 20.4625 12.75 20.25 12.75H3.75ZM3.75 7.5C3.5375 7.5 3.35938 7.42771 3.21563 7.28313C3.07187 7.13853 3 6.95936 3 6.74563C3 6.53188 3.07187 6.35417 3.21563 6.2125C3.35938 6.07083 3.5375 6 3.75 6H20.25C20.4625 6 20.6406 6.07229 20.7844 6.21687C20.9281 6.36147 21 6.54064 21 6.75437C21 6.96812 20.9281 7.14583 20.7844 7.2875C20.6406 7.42917 20.4625 7.5 20.25 7.5H3.75Z"
|
||||
fill="#36344D"></path>
|
||||
</svg>
|
||||
<?php
|
||||
if (!empty($submenus)) { ?>
|
||||
<ul class="hsr-wrapper__list">
|
||||
<?php
|
||||
|
||||
foreach ($submenus as $index => $submenu) {
|
||||
$page = (isset($_GET['page'])) ? $_GET['page'] : '';
|
||||
|
||||
$is_active = ($page === $submenu['menu_slug'] || ($page === self::MENU_SLUG && $index === 0));
|
||||
|
||||
?>
|
||||
<li
|
||||
class="hsr-list__item <?php echo ($is_active) ? "hsr-active" : ""; ?>"
|
||||
>
|
||||
<a
|
||||
href="<?php echo menu_page_url($submenu['menu_slug'], false); ?>"
|
||||
class="<?php echo $submenu['menu_slug']; ?>"
|
||||
>
|
||||
<?php
|
||||
|
||||
echo $submenu['menu_title'];
|
||||
|
||||
?>
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
?>
|
||||
</ul>
|
||||
<?php } ?>
|
||||
|
||||
<?php
|
||||
$utils = new Utils();
|
||||
$api_token = Utils::getApiToken();
|
||||
?>
|
||||
<div class="hsr-navbar-buttons">
|
||||
<?php if (get_site_url()) { ?>
|
||||
<div class="hts-preview-website">
|
||||
<a href="<?php echo esc_url(get_site_url()); ?>" target="_blank" rel="noopener">
|
||||
<?php echo esc_html__('Preview website', 'hostinger-wp-menu-package'); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if (!empty($api_token)) { ?>
|
||||
<div class="hts-hpanel">
|
||||
<a href="<?php echo esc_url($utils->getHpanelDomainUrl()); ?>" target="_blank" rel="noopener">
|
||||
<?php echo esc_html__('Go to Hostinger', 'hostinger-wp-menu-package'); ?>
|
||||
</a>
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M2.5 5.24609C2.5 3.72731 3.73122 2.49609 5.25 2.49609H6C6.41421 2.49609 6.75 2.83188 6.75 3.24609C6.75 3.66031 6.41421 3.99609 6 3.99609H5.25C4.55964 3.99609 4 4.55574 4 5.24609V10.6842C4 11.3745 4.55964 11.9342 5.25 11.9342H10.7508C11.4411 11.9342 12.0008 11.3745 12.0008 10.6842V9.99829C12.0008 9.58408 12.3366 9.24829 12.7508 9.24829C13.165 9.24829 13.5008 9.58408 13.5008 9.99829V10.6842C13.5008 12.203 12.2696 13.4342 10.7508 13.4342H5.25C3.73122 13.4342 2.5 12.203 2.5 10.6842V5.24609ZM12 5.05906L8.03033 9.02873C7.73744 9.32162 7.26256 9.32162 6.96967 9.02873C6.67678 8.73583 6.67678 8.26096 6.96967 7.96807L10.9393 3.9984L9 3.9984C8.58579 3.9984 8.25 3.66261 8.25 3.2484C8.25 2.83418 8.58579 2.4984 9 2.4984L12.25 2.4984C12.9404 2.4984 13.5 3.05804 13.5 3.7484V6.9984C13.5 7.41261 13.1642 7.7484 12.75 7.7484C12.3358 7.7484 12 7.41261 12 6.9984V5.05906Z" fill="#673DE6"/>
|
||||
</svg>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
@@ -0,0 +1,11 @@
|
||||
name: sca-scan
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [master, main, staging]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
run-sca:
|
||||
uses: hostinger/sca-configs/.github/workflows/sca.yml@main
|
||||
secrets: inherit
|
||||
@@ -0,0 +1,5 @@
|
||||
/.idea/
|
||||
/vendor
|
||||
/node_modules
|
||||
.phpunit.result.cache
|
||||
hostinger-surveys-package.php
|
||||
@@ -0,0 +1,96 @@
|
||||
# WordPress Hostinger Surveys PHP package
|
||||
|
||||
Package for managing Hostinger WordPress surveys.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Installation](#installation)
|
||||
- [Usage](#usage)
|
||||
- [Support](#support)
|
||||
|
||||
## Installation
|
||||
|
||||
This is private package, adding it to composer is a bit different.
|
||||
|
||||
Add it to the composer.json:
|
||||
```sh
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "git@github.com:hostinger/hostinger-wp-surveys.git"
|
||||
}
|
||||
],
|
||||
```
|
||||
|
||||
and:
|
||||
```sh
|
||||
"require": {
|
||||
"hostinger/hostinger-surveys": "main",
|
||||
}
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
First thing boot up package in main plugin file:
|
||||
|
||||
```sh
|
||||
use Hostinger\Surveys\Loader;
|
||||
if( !function_exists('hostinger_load_surveys') ) {
|
||||
function hostinger_load_surveys(): void {
|
||||
$surveys = Loader::get_instance();
|
||||
$surveys->boot();
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! has_action( 'plugins_loaded', 'hostinger_load_surveys' ) ) {
|
||||
add_action('plugins_loaded', 'hostinger_load_surveys');
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Then boot Surveys class with all surveys logic
|
||||
|
||||
```sh
|
||||
use Hostinger\Surveys\SurveyManager;
|
||||
if ( class_exists( SurveyManager::class ) ) {
|
||||
$surveys = new Surveys();
|
||||
$surveys->init();
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
And here is example of Surveys class
|
||||
|
||||
```sh
|
||||
<?php
|
||||
|
||||
namespace Hostinger\EasyOnboarding\Admin;
|
||||
|
||||
use Hostinger\Surveys\SurveyManager;
|
||||
|
||||
class Surveys {
|
||||
const CHATBOT_SURVEY_NAME = 'chatbot';
|
||||
const CHATBOT_SURVEY_SCORE_QUESTION = 'How would you rate our AI chatbot? (1-10)';
|
||||
const CHATBOT_SURVEY_COMMENT_QUESTION = 'How would you rate your experience with the Chatbot? (Comment)';
|
||||
const CHATBOT_SURVEY_LOCATION = 'wp-admin';
|
||||
const SURVEY_PRIORITY = 999;
|
||||
|
||||
public function init() {
|
||||
add_filter( 'hostinger_add_surveys', [ $this, 'createSurveys' ] );
|
||||
}
|
||||
|
||||
public function createSurveys( $surveys ) {
|
||||
$scoreQuestion = esc_html__( self::CHATBOT_SURVEY_SCORE_QUESTION, 'hostinger-easy-onboarding' );
|
||||
$commentQuestion = esc_html__( self::CHATBOT_SURVEY_COMMENT_QUESTION, 'hostinger-easy-onboarding' );
|
||||
$chatbotSurvey = SurveyManager::addSurvey( self::CHATBOT_SURVEY_NAME, $scoreQuestion, $commentQuestion, self::CHATBOT_SURVEY_LOCATION, self::SURVEY_PRIORITY );
|
||||
$surveys[] = $chatbotSurvey;
|
||||
|
||||
return $surveys;
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
Package initially was written by Martynas U. (martynas.umbraziunas@hostinger.com). You can ping him in Slack for support.
|
||||
@@ -0,0 +1 @@
|
||||
.hts-survey-wrapper{background:#fff;border:1px solid #dadce0;border-radius:4px 4px 0 0;bottom:0;box-shadow:0 0 12px rgba(29,30,32,.16);display:none;left:160px;margin-top:2rem;max-width:500px;padding:24px 32px;position:fixed}@media (max-width:960px){.hts-survey-wrapper{left:40px}}@media (max-width:780px){.hts-survey-wrapper{left:0}}.hts-survey-wrapper .close-btn{cursor:pointer;position:absolute;right:10px;top:10px}.hts-survey-wrapper .close-btn svg{height:20px;width:20px}@media (max-width:400px){.hts-survey-wrapper{padding:24px 15px}}@media (max-width:370px){.hts-survey-wrapper{padding:24px 10px}}.hts-survey-wrapper #hts-questionsLeft{color:#727586;display:none;font-size:14px;font-weight:400;line-height:24px}#hostinger-feedback-survey{direction:ltr}#hostinger-feedback-survey .sd-root-modern form textarea{border:1px solid #dadce0;border-radius:4px;color:#727586;padding:12px 16px;width:100%}#hostinger-feedback-survey .sd-root-modern form textarea:focus{border:1px solid #673de6}#hostinger-feedback-survey .sd-root-modern form .sd-question__header h5{font-size:19px;font-weight:700;letter-spacing:0;line-height:32px;margin-bottom:24px;margin-top:0;text-align:left}@media (max-width:450px){#hostinger-feedback-survey .sd-root-modern form .sd-question__header h5{font-size:16px;line-height:24px}}#hostinger-feedback-survey .sd-root-modern form .sd-btn{background:#673de6;border:none;border-radius:4px;color:#fff;cursor:pointer;flex-grow:0;font-weight:700;line-height:24px;margin:25px 0 0;padding:8px 24px;text-decoration:none}@media (max-width:450px){#hostinger-feedback-survey .sd-root-modern form .sd-btn{font-size:13px;padding:5px 15px}}#hostinger-feedback-survey .sd-root-modern form .sd-btn:hover{background:#5025d1}#hostinger-feedback-survey .sd-root-modern form .sd-action-bar{display:flex;justify-content:flex-end;margin:10px 0;position:relative}@media (max-width:450px){#hostinger-feedback-survey .sd-root-modern form .sd-action-bar{margin:5px 0}}#hostinger-feedback-survey .sd-root-modern form .sd-action-bar #sv-nav-prev{left:0;position:absolute;top:0}#hostinger-feedback-survey .sd-root-modern form .sd-rating{display:flex;justify-content:space-between;position:relative}#hostinger-feedback-survey .sd-root-modern form .sd-rating fieldset{align-items:center;display:flex;justify-content:space-between;width:100%}#hostinger-feedback-survey .sd-root-modern form .sd-rating .sd-rating__item--selected{background-color:#ebe4ff;border:1px solid #673de6}#hostinger-feedback-survey .sd-root-modern form .sd-rating .sd-rating__min-text{bottom:-25px;left:0;position:absolute}#hostinger-feedback-survey .sd-root-modern form .sd-rating .sd-rating__item-text{color:#727586;font-size:14px;font-weight:400;line-height:24px}#hostinger-feedback-survey .sd-root-modern form .sd-rating .sd-rating__max-text{bottom:-25px;position:absolute;right:0}#hostinger-feedback-survey .sd-root-modern form .sd-rating__item{align-items:center;border:1px solid #dadce0;border-radius:100%;color:#673de6;cursor:pointer;display:flex;height:30px;justify-content:center;margin:0;text-align:center;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:30px}#hostinger-feedback-survey .sd-root-modern form .sd-rating__item:hover{background-color:#ebe4ff;border:1px solid #673de6}#hostinger-feedback-survey .sd-root-modern form .sd-rating__item .sd-rating__item-text,#hostinger-feedback-survey .sd-root-modern form .sd-rating__item input{margin:0}#hostinger-feedback-survey .sd-root-modern form .sv-visuallyhidden[type=radio]{opacity:0;pointer-events:none;position:absolute}#hostinger-feedback-survey .sd-root-modern form .sd-rating__item-text{margin-left:5px}#hostinger-feedback-survey .sd-root-modern form .sd-remaining-character-counter{color:#727586;font-size:14px;font-weight:400;line-height:24px}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "hostinger/hostinger-wp-surveys",
|
||||
"description": "A PHP package with surveys for WordPress plugins",
|
||||
"license": "proprietary",
|
||||
"type": "library",
|
||||
"version": "1.1.7",
|
||||
"require": {
|
||||
"php": ">=8.0",
|
||||
"hostinger/hostinger-wp-helper": "dev-main"
|
||||
},
|
||||
"require-dev": {
|
||||
"squizlabs/php_codesniffer": "^3.0",
|
||||
"brain/monkey": "^2.6",
|
||||
"phpunit/phpunit": "^9.6",
|
||||
"10up/wp_mock": "^1.0"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "git@github.com:hostinger/hostinger-wp-helper.git"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Hostinger\\Surveys\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Hostinger\\Surveys\\Tests\\": "tests/phpunit"
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,53 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Surveys package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: Mohamed Doukkali\n"
|
||||
"Language-Team: Arabic\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-05-13T05:29:33+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-13 09:37+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-surveys\n"
|
||||
"Language: ar\n"
|
||||
"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100 >= 3 "
|
||||
"&& n%100<=10 ? 3 : n%100 >= 11 && n%100<=99 ? 4 : 5;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: src/SurveyManager.php:166
|
||||
msgid "Next"
|
||||
msgstr "التالي"
|
||||
|
||||
#: src/SurveyManager.php:167
|
||||
msgid "Previous"
|
||||
msgstr "السابق"
|
||||
|
||||
#: src/SurveyManager.php:168
|
||||
msgid "Submit"
|
||||
msgstr "إرسال"
|
||||
|
||||
#: src/SurveyManager.php:169
|
||||
msgid "Thank you for completing the survey !"
|
||||
msgstr "شكرًا لك على إكمال الاستبيان!"
|
||||
|
||||
#: src/SurveyManager.php:178
|
||||
msgid "Response required."
|
||||
msgstr "الجواب مطلوب"
|
||||
|
||||
#: src/SurveyManager.php:188
|
||||
msgid "Poor"
|
||||
msgstr "سيئ"
|
||||
|
||||
#: src/SurveyManager.php:189
|
||||
msgid "Excellent"
|
||||
msgstr "ممتاز"
|
||||
|
||||
#: src/SurveyManager.php:237
|
||||
msgid "Question"
|
||||
msgstr "السؤال"
|
||||
|
||||
#: src/SurveyManager.php:243
|
||||
msgid "of "
|
||||
msgstr "من"
|
||||
Binary file not shown.
@@ -0,0 +1,52 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Surveys package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: German\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-05-13T05:29:33+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-16 10:55+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-surveys\n"
|
||||
"Language: de_DE\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: src/SurveyManager.php:166
|
||||
msgid "Next"
|
||||
msgstr "Weiter"
|
||||
|
||||
#: src/SurveyManager.php:167
|
||||
msgid "Previous"
|
||||
msgstr "Vorherige"
|
||||
|
||||
#: src/SurveyManager.php:168
|
||||
msgid "Submit"
|
||||
msgstr "Abschicken"
|
||||
|
||||
#: src/SurveyManager.php:169
|
||||
msgid "Thank you for completing the survey !"
|
||||
msgstr "Vielen Dank für die Teilnahme an der Umfrage!"
|
||||
|
||||
#: src/SurveyManager.php:178
|
||||
msgid "Response required."
|
||||
msgstr "Antwort erforderlich."
|
||||
|
||||
#: src/SurveyManager.php:188
|
||||
msgid "Poor"
|
||||
msgstr "Schlecht"
|
||||
|
||||
#: src/SurveyManager.php:189
|
||||
msgid "Excellent"
|
||||
msgstr "Ausgezeichnet"
|
||||
|
||||
#: src/SurveyManager.php:237
|
||||
msgid "Question"
|
||||
msgstr "Frage"
|
||||
|
||||
#: src/SurveyManager.php:243
|
||||
msgid "of "
|
||||
msgstr "von"
|
||||
Binary file not shown.
@@ -0,0 +1,52 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Surveys package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: Spanish (Spain)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-05-13T05:29:33+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-15 18:05+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-surveys\n"
|
||||
"Language: es_ES\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: src/SurveyManager.php:166
|
||||
msgid "Next"
|
||||
msgstr "Siguiente"
|
||||
|
||||
#: src/SurveyManager.php:167
|
||||
msgid "Previous"
|
||||
msgstr "Anterior"
|
||||
|
||||
#: src/SurveyManager.php:168
|
||||
msgid "Submit"
|
||||
msgstr "Enviar"
|
||||
|
||||
#: src/SurveyManager.php:169
|
||||
msgid "Thank you for completing the survey !"
|
||||
msgstr "Gracias por completar la encuesta."
|
||||
|
||||
#: src/SurveyManager.php:178
|
||||
msgid "Response required."
|
||||
msgstr "Respuesta requerida."
|
||||
|
||||
#: src/SurveyManager.php:188
|
||||
msgid "Poor"
|
||||
msgstr "Deficiente"
|
||||
|
||||
#: src/SurveyManager.php:189
|
||||
msgid "Excellent"
|
||||
msgstr "Excelente"
|
||||
|
||||
#: src/SurveyManager.php:237
|
||||
msgid "Question"
|
||||
msgstr "Pregunta"
|
||||
|
||||
#: src/SurveyManager.php:243
|
||||
msgid "of "
|
||||
msgstr "de"
|
||||
Binary file not shown.
@@ -0,0 +1,52 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Surveys package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: French (France)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-05-13T05:29:33+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-13 11:11+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-surveys\n"
|
||||
"Language: fr_FR\n"
|
||||
"Plural-Forms: nplurals=2; plural=n > 1;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: src/SurveyManager.php:166
|
||||
msgid "Next"
|
||||
msgstr "Suivant"
|
||||
|
||||
#: src/SurveyManager.php:167
|
||||
msgid "Previous"
|
||||
msgstr "Précédent"
|
||||
|
||||
#: src/SurveyManager.php:168
|
||||
msgid "Submit"
|
||||
msgstr "Soumettre"
|
||||
|
||||
#: src/SurveyManager.php:169
|
||||
msgid "Thank you for completing the survey !"
|
||||
msgstr "Merci d'avoir répondu au questionnaire !"
|
||||
|
||||
#: src/SurveyManager.php:178
|
||||
msgid "Response required."
|
||||
msgstr "Réponse requise."
|
||||
|
||||
#: src/SurveyManager.php:188
|
||||
msgid "Poor"
|
||||
msgstr "Faible"
|
||||
|
||||
#: src/SurveyManager.php:189
|
||||
msgid "Excellent"
|
||||
msgstr "Excellent"
|
||||
|
||||
#: src/SurveyManager.php:237
|
||||
msgid "Question"
|
||||
msgstr "Question"
|
||||
|
||||
#: src/SurveyManager.php:243
|
||||
msgid "of "
|
||||
msgstr "de "
|
||||
Binary file not shown.
@@ -0,0 +1,52 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Surveys package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: Hindi\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-05-13T05:29:33+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-13 09:29+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-surveys\n"
|
||||
"Language: hi_IN\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: src/SurveyManager.php:166
|
||||
msgid "Next"
|
||||
msgstr "अगला"
|
||||
|
||||
#: src/SurveyManager.php:167
|
||||
msgid "Previous"
|
||||
msgstr "पिछला"
|
||||
|
||||
#: src/SurveyManager.php:168
|
||||
msgid "Submit"
|
||||
msgstr "सबमिट करें"
|
||||
|
||||
#: src/SurveyManager.php:169
|
||||
msgid "Thank you for completing the survey !"
|
||||
msgstr "सर्वे पूरा करने के लिए धन्यवाद!"
|
||||
|
||||
#: src/SurveyManager.php:178
|
||||
msgid "Response required."
|
||||
msgstr "प्रतिक्रिया आवश्यक है"
|
||||
|
||||
#: src/SurveyManager.php:188
|
||||
msgid "Poor"
|
||||
msgstr "खराब"
|
||||
|
||||
#: src/SurveyManager.php:189
|
||||
msgid "Excellent"
|
||||
msgstr "बहुत अच्छे"
|
||||
|
||||
#: src/SurveyManager.php:237
|
||||
msgid "Question"
|
||||
msgstr "सवाल"
|
||||
|
||||
#: src/SurveyManager.php:243
|
||||
msgid "of "
|
||||
msgstr "का"
|
||||
Binary file not shown.
@@ -0,0 +1,52 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Surveys package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: Indonesian\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-05-13T05:29:33+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-16 03:37+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-surveys\n"
|
||||
"Language: id_ID\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: src/SurveyManager.php:166
|
||||
msgid "Next"
|
||||
msgstr "Selanjutnya"
|
||||
|
||||
#: src/SurveyManager.php:167
|
||||
msgid "Previous"
|
||||
msgstr "Sebelumnya"
|
||||
|
||||
#: src/SurveyManager.php:168
|
||||
msgid "Submit"
|
||||
msgstr "Kirim"
|
||||
|
||||
#: src/SurveyManager.php:169
|
||||
msgid "Thank you for completing the survey !"
|
||||
msgstr "Terima kasih telah mengisi survei ini!"
|
||||
|
||||
#: src/SurveyManager.php:178
|
||||
msgid "Response required."
|
||||
msgstr "Wajib diisi."
|
||||
|
||||
#: src/SurveyManager.php:188
|
||||
msgid "Poor"
|
||||
msgstr "Tidak puas"
|
||||
|
||||
#: src/SurveyManager.php:189
|
||||
msgid "Excellent"
|
||||
msgstr "Sangat puas"
|
||||
|
||||
#: src/SurveyManager.php:237
|
||||
msgid "Question"
|
||||
msgstr "Pertanyaan"
|
||||
|
||||
#: src/SurveyManager.php:243
|
||||
msgid "of "
|
||||
msgstr "dari"
|
||||
Binary file not shown.
@@ -0,0 +1,52 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Surveys package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: Italian\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-05-13T05:29:33+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-13 09:58+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-surveys\n"
|
||||
"Language: it_IT\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: src/SurveyManager.php:166
|
||||
msgid "Next"
|
||||
msgstr "Successivo"
|
||||
|
||||
#: src/SurveyManager.php:167
|
||||
msgid "Previous"
|
||||
msgstr "Precedente"
|
||||
|
||||
#: src/SurveyManager.php:168
|
||||
msgid "Submit"
|
||||
msgstr "Invia"
|
||||
|
||||
#: src/SurveyManager.php:169
|
||||
msgid "Thank you for completing the survey !"
|
||||
msgstr "Grazie per aver completato il sondaggio!"
|
||||
|
||||
#: src/SurveyManager.php:178
|
||||
msgid "Response required."
|
||||
msgstr "È richiesta una risposta."
|
||||
|
||||
#: src/SurveyManager.php:188
|
||||
msgid "Poor"
|
||||
msgstr "Scarso"
|
||||
|
||||
#: src/SurveyManager.php:189
|
||||
msgid "Excellent"
|
||||
msgstr "Eccellente"
|
||||
|
||||
#: src/SurveyManager.php:237
|
||||
msgid "Question"
|
||||
msgstr "Domanda"
|
||||
|
||||
#: src/SurveyManager.php:243
|
||||
msgid "of "
|
||||
msgstr "di"
|
||||
Binary file not shown.
@@ -0,0 +1,53 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Surveys package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: Milda\n"
|
||||
"Language-Team: Lietuvių kalba\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-05-13T05:29:33+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-16 07:15+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-surveys\n"
|
||||
"Language: lt_LT\n"
|
||||
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10 >= 2 "
|
||||
"&&(n%100<10||n%100 >= 20)? 1 : 2);\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: src/SurveyManager.php:166
|
||||
msgid "Next"
|
||||
msgstr "Toliau"
|
||||
|
||||
#: src/SurveyManager.php:167
|
||||
msgid "Previous"
|
||||
msgstr "Ankstesnis"
|
||||
|
||||
#: src/SurveyManager.php:168
|
||||
msgid "Submit"
|
||||
msgstr "Pateikti"
|
||||
|
||||
#: src/SurveyManager.php:169
|
||||
msgid "Thank you for completing the survey !"
|
||||
msgstr "Dėkojame, kad užpildei apklausą!"
|
||||
|
||||
#: src/SurveyManager.php:178
|
||||
msgid "Response required."
|
||||
msgstr "Atsakyti privaloma."
|
||||
|
||||
#: src/SurveyManager.php:188
|
||||
msgid "Poor"
|
||||
msgstr "Prastai"
|
||||
|
||||
#: src/SurveyManager.php:189
|
||||
msgid "Excellent"
|
||||
msgstr "Puikiai"
|
||||
|
||||
#: src/SurveyManager.php:237
|
||||
msgid "Question"
|
||||
msgstr "Klausimas"
|
||||
|
||||
#: src/SurveyManager.php:243
|
||||
msgid "of "
|
||||
msgstr "iš"
|
||||
Binary file not shown.
@@ -0,0 +1,52 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Surveys package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: Dutch\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-05-13T05:29:33+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-14 02:45+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-surveys\n"
|
||||
"Language: nl_NL\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: src/SurveyManager.php:166
|
||||
msgid "Next"
|
||||
msgstr "Volgende"
|
||||
|
||||
#: src/SurveyManager.php:167
|
||||
msgid "Previous"
|
||||
msgstr "Vorige"
|
||||
|
||||
#: src/SurveyManager.php:168
|
||||
msgid "Submit"
|
||||
msgstr "Indienen"
|
||||
|
||||
#: src/SurveyManager.php:169
|
||||
msgid "Thank you for completing the survey !"
|
||||
msgstr "Bedankt voor het invullen van de enquête!"
|
||||
|
||||
#: src/SurveyManager.php:178
|
||||
msgid "Response required."
|
||||
msgstr "Reactie vereist"
|
||||
|
||||
#: src/SurveyManager.php:188
|
||||
msgid "Poor"
|
||||
msgstr "Slecht"
|
||||
|
||||
#: src/SurveyManager.php:189
|
||||
msgid "Excellent"
|
||||
msgstr "Uitstekend"
|
||||
|
||||
#: src/SurveyManager.php:237
|
||||
msgid "Question"
|
||||
msgstr "Vraag"
|
||||
|
||||
#: src/SurveyManager.php:243
|
||||
msgid "of "
|
||||
msgstr "van"
|
||||
Binary file not shown.
@@ -0,0 +1,53 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Surveys package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: Portuguese (Brazil)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-05-13T05:29:33+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-15 14:57+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-surveys\n"
|
||||
"Language: pt_BR\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: src/SurveyManager.php:166
|
||||
msgid "Next"
|
||||
msgstr "Próximo"
|
||||
|
||||
#: src/SurveyManager.php:167
|
||||
msgid "Previous"
|
||||
msgstr "Anterior"
|
||||
|
||||
#: src/SurveyManager.php:168
|
||||
msgid "Submit"
|
||||
msgstr "Enviar"
|
||||
|
||||
#: src/SurveyManager.php:169
|
||||
msgid "Thank you for completing the survey !"
|
||||
msgstr ""
|
||||
"Obrigado por completar a pesquisa!\n"
|
||||
|
||||
#: src/SurveyManager.php:178
|
||||
msgid "Response required."
|
||||
msgstr "Resposta obrigátoria."
|
||||
|
||||
#: src/SurveyManager.php:188
|
||||
msgid "Poor"
|
||||
msgstr "Ruim"
|
||||
|
||||
#: src/SurveyManager.php:189
|
||||
msgid "Excellent"
|
||||
msgstr "Excelente"
|
||||
|
||||
#: src/SurveyManager.php:237
|
||||
msgid "Question"
|
||||
msgstr "Pergunta"
|
||||
|
||||
#: src/SurveyManager.php:243
|
||||
msgid "of "
|
||||
msgstr "de"
|
||||
Binary file not shown.
@@ -0,0 +1,52 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Surveys package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: Português\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-05-13T05:29:33+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-14 04:09+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-surveys\n"
|
||||
"Language: pt_PT\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: src/SurveyManager.php:166
|
||||
msgid "Next"
|
||||
msgstr "Próximo"
|
||||
|
||||
#: src/SurveyManager.php:167
|
||||
msgid "Previous"
|
||||
msgstr "Anterior"
|
||||
|
||||
#: src/SurveyManager.php:168
|
||||
msgid "Submit"
|
||||
msgstr "Submeter"
|
||||
|
||||
#: src/SurveyManager.php:169
|
||||
msgid "Thank you for completing the survey !"
|
||||
msgstr "Obrigado por completar o inquérito !"
|
||||
|
||||
#: src/SurveyManager.php:178
|
||||
msgid "Response required."
|
||||
msgstr "Resposta obrigatória."
|
||||
|
||||
#: src/SurveyManager.php:188
|
||||
msgid "Poor"
|
||||
msgstr "Mau"
|
||||
|
||||
#: src/SurveyManager.php:189
|
||||
msgid "Excellent"
|
||||
msgstr "Excelente"
|
||||
|
||||
#: src/SurveyManager.php:237
|
||||
msgid "Question"
|
||||
msgstr "Questão"
|
||||
|
||||
#: src/SurveyManager.php:243
|
||||
msgid "of "
|
||||
msgstr "de"
|
||||
Binary file not shown.
@@ -0,0 +1,52 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Surveys package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: Türkçe\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-05-13T05:29:33+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-14 12:47+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-surveys\n"
|
||||
"Language: tr_TR\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: src/SurveyManager.php:189
|
||||
msgid "Excellent"
|
||||
msgstr "Harika"
|
||||
|
||||
#: src/SurveyManager.php:166
|
||||
msgid "Next"
|
||||
msgstr "Sonraki"
|
||||
|
||||
#: src/SurveyManager.php:243
|
||||
msgid "of "
|
||||
msgstr "-"
|
||||
|
||||
#: src/SurveyManager.php:188
|
||||
msgid "Poor"
|
||||
msgstr "Kötü"
|
||||
|
||||
#: src/SurveyManager.php:167
|
||||
msgid "Previous"
|
||||
msgstr "Önceki"
|
||||
|
||||
#: src/SurveyManager.php:237
|
||||
msgid "Question"
|
||||
msgstr "Soru"
|
||||
|
||||
#: src/SurveyManager.php:178
|
||||
msgid "Response required."
|
||||
msgstr "Yanıt gerekiyor."
|
||||
|
||||
#: src/SurveyManager.php:168
|
||||
msgid "Submit"
|
||||
msgstr "Gönder"
|
||||
|
||||
#: src/SurveyManager.php:169
|
||||
msgid "Thank you for completing the survey !"
|
||||
msgstr "Anketi tamamladığınız için teşekkür ederiz!"
|
||||
Binary file not shown.
@@ -0,0 +1,53 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Surveys package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: Julia\n"
|
||||
"Language-Team: Українська\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-05-13T05:29:33+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-15 19:13+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-surveys\n"
|
||||
"Language: uk\n"
|
||||
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10 >= 2 && "
|
||||
"n%10<=4 &&(n%100<10||n%100 >= 20)? 1 : 2);\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: src/SurveyManager.php:166
|
||||
msgid "Next"
|
||||
msgstr "Далі"
|
||||
|
||||
#: src/SurveyManager.php:167
|
||||
msgid "Previous"
|
||||
msgstr "Назад"
|
||||
|
||||
#: src/SurveyManager.php:168
|
||||
msgid "Submit"
|
||||
msgstr "Надіслати"
|
||||
|
||||
#: src/SurveyManager.php:169
|
||||
msgid "Thank you for completing the survey !"
|
||||
msgstr "Дякуємо за участь в опитуванні!"
|
||||
|
||||
#: src/SurveyManager.php:178
|
||||
msgid "Response required."
|
||||
msgstr "Потрібна відповідь."
|
||||
|
||||
#: src/SurveyManager.php:188
|
||||
msgid "Poor"
|
||||
msgstr "Погано"
|
||||
|
||||
#: src/SurveyManager.php:189
|
||||
msgid "Excellent"
|
||||
msgstr "Чудово"
|
||||
|
||||
#: src/SurveyManager.php:237
|
||||
msgid "Question"
|
||||
msgstr "Запитання"
|
||||
|
||||
#: src/SurveyManager.php:243
|
||||
msgid "of "
|
||||
msgstr "з"
|
||||
Binary file not shown.
@@ -0,0 +1,52 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Hostinger WordPress Surveys package\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: Zhou Yu\n"
|
||||
"Language-Team: 简体中文\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-05-13T05:29:33+00:00\n"
|
||||
"PO-Revision-Date: 2024-05-15 02:16+0000\n"
|
||||
"X-Generator: Loco https://localise.biz/\n"
|
||||
"X-Domain: hostinger-wp-surveys\n"
|
||||
"Language: zh_CN\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"X-Loco-Version: 2.6.7; wp-6.4.4"
|
||||
|
||||
#: src/SurveyManager.php:166
|
||||
msgid "Next"
|
||||
msgstr "下一个"
|
||||
|
||||
#: src/SurveyManager.php:167
|
||||
msgid "Previous"
|
||||
msgstr "上一个"
|
||||
|
||||
#: src/SurveyManager.php:168
|
||||
msgid "Submit"
|
||||
msgstr "提交"
|
||||
|
||||
#: src/SurveyManager.php:169
|
||||
msgid "Thank you for completing the survey !"
|
||||
msgstr "感谢你完成了此问卷!"
|
||||
|
||||
#: src/SurveyManager.php:178
|
||||
msgid "Response required."
|
||||
msgstr "请做出回应"
|
||||
|
||||
#: src/SurveyManager.php:188
|
||||
msgid "Poor"
|
||||
msgstr "差"
|
||||
|
||||
#: src/SurveyManager.php:189
|
||||
msgid "Excellent"
|
||||
msgstr "好极了!"
|
||||
|
||||
#: src/SurveyManager.php:237
|
||||
msgid "Question"
|
||||
msgstr "问题"
|
||||
|
||||
#: src/SurveyManager.php:243
|
||||
msgid "of "
|
||||
msgstr "的"
|
||||
@@ -0,0 +1,49 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-05-13T05:29:33+00:00\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"X-Generator: WP-CLI 2.8.1\n"
|
||||
"X-Domain: hostinger-wp-surveys\n"
|
||||
|
||||
#: src/SurveyManager.php:166
|
||||
msgid "Next"
|
||||
msgstr ""
|
||||
|
||||
#: src/SurveyManager.php:167
|
||||
msgid "Previous"
|
||||
msgstr ""
|
||||
|
||||
#: src/SurveyManager.php:168
|
||||
msgid "Submit"
|
||||
msgstr ""
|
||||
|
||||
#: src/SurveyManager.php:169
|
||||
msgid "Thank you for completing the survey !"
|
||||
msgstr ""
|
||||
|
||||
#: src/SurveyManager.php:178
|
||||
msgid "Response required."
|
||||
msgstr ""
|
||||
|
||||
#: src/SurveyManager.php:188
|
||||
msgid "Poor"
|
||||
msgstr ""
|
||||
|
||||
#: src/SurveyManager.php:189
|
||||
msgid "Excellent"
|
||||
msgstr ""
|
||||
|
||||
#: src/SurveyManager.php:237
|
||||
msgid "Question"
|
||||
msgstr ""
|
||||
|
||||
#: src/SurveyManager.php:243
|
||||
msgid "of "
|
||||
msgstr ""
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace Hostinger\Surveys;
|
||||
|
||||
use Hostinger\WpHelper\Config;
|
||||
use Hostinger\WpHelper\Utils as Helper;
|
||||
use Hostinger\WpHelper\Requests\Client;
|
||||
use Hostinger\WpHelper\Constants;
|
||||
use Hostinger\Surveys\Rest as SurveysRest;
|
||||
use Hostinger\Surveys\SurveyManager as HostingerSurveys;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
class Ajax
|
||||
{
|
||||
private const HIDE_SURVEY_TRANSIENT = 'hts_hide_survey';
|
||||
private const THIRTY_DAYS = 86400 * 30;
|
||||
|
||||
private Config $configHandler;
|
||||
private Helper $helper;
|
||||
private SurveysRest $surveysRest;
|
||||
|
||||
public function __construct(
|
||||
Helper $helper,
|
||||
Config $configHandler,
|
||||
Rest $surveysRest
|
||||
) {
|
||||
$this->helper = $helper;
|
||||
$this->configHandler = $configHandler;
|
||||
$this->surveysRest = $surveysRest;
|
||||
|
||||
add_action('init', [ $this, 'defineAjaxEvents' ], 0);
|
||||
}
|
||||
|
||||
public function defineAjaxEvents(): void
|
||||
{
|
||||
$events = [
|
||||
'submitSurvey',
|
||||
'hideSurvey',
|
||||
];
|
||||
|
||||
foreach ($events as $event) {
|
||||
add_action('wp_ajax_hostinger_' . $event, [ $this, $event ]);
|
||||
}
|
||||
}
|
||||
|
||||
public function submitSurvey(): void
|
||||
{
|
||||
$nonce = isset($_POST['nonce']) ? sanitize_text_field($_POST['nonce']) : '';
|
||||
$survey_results = isset($_POST['survey_results']) ? sanitize_text_field($_POST['survey_results']) : '';
|
||||
$survey_location = isset($_POST['survey_location']) ? sanitize_text_field($_POST['survey_location']) : '';
|
||||
$survey_id = isset($_POST['survey_id']) ? sanitize_text_field($_POST['survey_id']) : '';
|
||||
$surveys = new HostingerSurveys($this->helper, $this->configHandler, $this->surveysRest);
|
||||
|
||||
$security_check = $this->requestSecurityCheck($nonce);
|
||||
|
||||
if (! empty($security_check)) {
|
||||
wp_send_json_error($security_check);
|
||||
}
|
||||
|
||||
$decoded_json = json_decode(stripslashes($survey_results), true);
|
||||
$surveys->submitSurveyAnswers($decoded_json, $survey_id, $survey_location);
|
||||
}
|
||||
|
||||
public function hideSurvey(): void
|
||||
{
|
||||
$nonce = isset($_POST['nonce']) ? sanitize_text_field($_POST['nonce']) : '';
|
||||
$transient_key = self::HIDE_SURVEY_TRANSIENT;
|
||||
$security_check = $this->requestSecurityCheck($nonce);
|
||||
|
||||
if (! empty($security_check)) {
|
||||
wp_send_json_error($security_check);
|
||||
}
|
||||
|
||||
if (false === get_transient($transient_key)) {
|
||||
set_transient($transient_key, time(), self::THIRTY_DAYS);
|
||||
}
|
||||
|
||||
wp_send_json_success([]);
|
||||
}
|
||||
|
||||
public function requestSecurityCheck($nonce)
|
||||
{
|
||||
if (! wp_verify_nonce($nonce, 'hts-ajax-nonce')) {
|
||||
return 'Invalid nonce';
|
||||
}
|
||||
|
||||
if (! current_user_can('manage_options')) {
|
||||
return 'Lack of permissions';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Hostinger\Surveys;
|
||||
|
||||
class Assets
|
||||
{
|
||||
public Loader $surveys;
|
||||
public function init(): void
|
||||
{
|
||||
add_action('admin_enqueue_scripts', [ $this, 'enqueueAdminAssets' ]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function enqueueAdminAssets(): void
|
||||
{
|
||||
$composerJsonPath = __DIR__ . '/../composer.json';
|
||||
if (file_exists($composerJsonPath)) {
|
||||
$composerConfig = json_decode(file_get_contents($composerJsonPath), true);
|
||||
$version = $composerConfig['version'] ?? '1';
|
||||
}
|
||||
|
||||
$pluginInfo = $this->surveys->getPluginInfo();
|
||||
$jsScriptPath = $pluginInfo . '/vendor/hostinger/hostinger-wp-surveys/assets/js/hostinger-surveys.min.js';
|
||||
$cssStylePath = $pluginInfo . '/vendor/hostinger/hostinger-wp-surveys/assets/css/style.min.css';
|
||||
|
||||
wp_enqueue_script(
|
||||
'hostinger_surveys_scripts',
|
||||
$jsScriptPath,
|
||||
['jquery'],
|
||||
$version,
|
||||
['strategy' => 'defer']
|
||||
);
|
||||
wp_localize_script(
|
||||
'hostinger_surveys_scripts',
|
||||
'hostingerContainer',
|
||||
[
|
||||
'url' => admin_url('admin-ajax.php'),
|
||||
'nonce' => wp_create_nonce('hts-ajax-nonce'),
|
||||
]
|
||||
);
|
||||
wp_enqueue_style(
|
||||
'hostinger_surveys_styles',
|
||||
$cssStylePath,
|
||||
[],
|
||||
$version
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace Hostinger\Surveys;
|
||||
|
||||
use Hostinger\WpHelper\Config;
|
||||
use Hostinger\WpHelper\Constants;
|
||||
use Hostinger\WpHelper\Requests\Client;
|
||||
use Hostinger\WpHelper\Utils;
|
||||
use Hostinger\Surveys\Ajax as SurveysAjax;
|
||||
|
||||
class Loader
|
||||
{
|
||||
/**
|
||||
* @var Loader instance.
|
||||
*/
|
||||
private static ?Loader $instance = null;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private array $objects = [];
|
||||
|
||||
/**
|
||||
* Allow only one instance of class
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function getInstance(): self
|
||||
{
|
||||
if (null === self::$instance) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function boot(): bool
|
||||
{
|
||||
$this->registerModules();
|
||||
$this->loadTextDomain();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function registerModules(): void
|
||||
{
|
||||
// Surveys.
|
||||
$helper = new Utils();
|
||||
$configHandler = new Config();
|
||||
$surveyRest = new Rest(
|
||||
new Client(
|
||||
$configHandler->getConfigValue('base_rest_uri', Constants::HOSTINGER_REST_URI),
|
||||
[
|
||||
Config::TOKEN_HEADER => $helper::getApiToken(),
|
||||
Config::DOMAIN_HEADER => $helper->getHostInfo(),
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
$this->objects['ajax'] = new SurveysAjax($helper, $configHandler, $surveyRest);
|
||||
|
||||
// Assets.
|
||||
$this->objects['assets'] = new Assets();
|
||||
$this->objects['assets']->init();
|
||||
|
||||
$this->objects['survey_loader'] = new SurveyLoader();
|
||||
$this->objects['survey_loader']->run();
|
||||
|
||||
$this->addContainer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function addContainer(): bool
|
||||
{
|
||||
if (empty($this->objects)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($this->objects as $object) {
|
||||
if (property_exists($object, 'surveys')) {
|
||||
$object->surveys = $this;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPluginInfo(): string
|
||||
{
|
||||
$plugin_url = '';
|
||||
|
||||
$plugins = get_plugins();
|
||||
foreach ($plugins as $plugin_path => $plugin_info) {
|
||||
if (str_contains(__FILE__, 'plugins/' . dirname($plugin_path) . '/')) {
|
||||
$plugin_dir = dirname($plugin_path);
|
||||
|
||||
return plugins_url($plugin_dir);
|
||||
}
|
||||
}
|
||||
|
||||
return $plugin_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function loadTextDomain(): void
|
||||
{
|
||||
load_plugin_textdomain(
|
||||
'hostinger-wp-surveys',
|
||||
false,
|
||||
dirname(dirname(plugin_basename(__FILE__))) . '/languages/'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace Hostinger\Surveys;
|
||||
|
||||
use Hostinger\WpHelper\Requests\Client;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
class Rest
|
||||
{
|
||||
public const SUBMIT_SURVEY = '/v3/wordpress/survey/store';
|
||||
public const CLIENT_SURVEY_ELIGIBILITY = '/v3/wordpress/survey/client-eligible';
|
||||
public const CLIENT_SURVEY_IDENTIFIER = 'customer_satisfaction_score';
|
||||
|
||||
private Client $client;
|
||||
|
||||
public function __construct(Client $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
public function isClientEligible(): bool
|
||||
{
|
||||
$response = $this->client->get(
|
||||
self::CLIENT_SURVEY_ELIGIBILITY,
|
||||
[
|
||||
'identifier' => self::CLIENT_SURVEY_IDENTIFIER,
|
||||
],
|
||||
[],
|
||||
10
|
||||
);
|
||||
|
||||
$decoded_response = $this->decodeResponse($response);
|
||||
$response_data = $decoded_response['response_data']['data'] ?? null;
|
||||
|
||||
if ($response_data !== true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) $this->getResult($response);
|
||||
}
|
||||
|
||||
public function submitSurveyData(array $data): bool
|
||||
{
|
||||
$response = $this->client->post(self::SUBMIT_SURVEY, $data);
|
||||
return $this->getResult($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|WP_Error $response
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getResult($response)
|
||||
{
|
||||
$data = $this->decodeResponse($response);
|
||||
|
||||
if (is_wp_error($data) || $data['response_code'] !== 200) {
|
||||
error_log('Error: ' . $data['response_body']);
|
||||
return false;
|
||||
}
|
||||
|
||||
return $data['response_data']['data'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|WP_Error $response
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function decodeResponse($response): array
|
||||
{
|
||||
$response_body = wp_remote_retrieve_body($response);
|
||||
$response_code = wp_remote_retrieve_response_code($response);
|
||||
$response_data = json_decode($response_body, true);
|
||||
|
||||
if (! is_array($response_data)) {
|
||||
$response_data = [ 'data' => null ];
|
||||
}
|
||||
|
||||
return [
|
||||
'response_code' => $response_code,
|
||||
'response_data' => $response_data,
|
||||
'response_body' => $response_body,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Hostinger\Surveys;
|
||||
|
||||
use Hostinger\Surveys\Rest;
|
||||
use Hostinger\Surveys\SurveyManager;
|
||||
use Hostinger\WpHelper\Requests\Client as RequestClient;
|
||||
use Hostinger\WpHelper\Config;
|
||||
use Hostinger\WpHelper\Utils as Helper;
|
||||
use Hostinger\WpHelper\Constants;
|
||||
|
||||
class SurveyLoader
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
if (is_admin()) {
|
||||
$this->showSurvey();
|
||||
}
|
||||
}
|
||||
|
||||
private function showSurvey(): void
|
||||
{
|
||||
$helper = new Helper();
|
||||
$configHandler = new Config();
|
||||
$client = new RequestClient(
|
||||
$configHandler->getConfigValue('base_rest_uri', Constants::HOSTINGER_REST_URI),
|
||||
[
|
||||
Config::TOKEN_HEADER => $helper::getApiToken(),
|
||||
Config::DOMAIN_HEADER => $helper->getHostInfo(),
|
||||
]
|
||||
);
|
||||
$rest = new Rest($client);
|
||||
$surveys = new SurveyManager($helper, $configHandler, $rest);
|
||||
|
||||
add_action('admin_footer', [ $surveys, 'activeSurveyHtml' ], 10);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,372 @@
|
||||
<?php
|
||||
|
||||
namespace Hostinger\Surveys;
|
||||
|
||||
use Hostinger\WpHelper\Config;
|
||||
use Hostinger\WpHelper\Utils as Helper;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
class SurveyManager
|
||||
{
|
||||
public const CACHE_THREE_HOURS = 3600 * 3;
|
||||
public const TIME_24_HOURS = 86400;
|
||||
public const CLIENT_SURVEY_IDENTIFIER = 'customer_satisfaction_score';
|
||||
public const CLIENT_WOO_COMPLETED_ACTIONS = 'woocommerce_task_list_tracked_completed_tasks';
|
||||
public const SUBMITTED_SURVEY_TRANSIENT = 'submitted_survey_transient';
|
||||
public const IS_CLIENT_ELIGIBLE_TRANSIENT_RESPONSE = 'client_eligibility_transient_response';
|
||||
public const IS_CLIENT_ELIGIBLE_TRANSIENT_REQUEST = 'survey_questions_transient_request';
|
||||
public const LOCATION_SLUG = 'location';
|
||||
public const HIDE_SURVEY_TRANSIENT = 'hts_hide_survey';
|
||||
public const WOOCOMMERCE_PAGES = [
|
||||
'/wp-admin/admin.php?page=wc-admin',
|
||||
'/wp-admin/edit.php?post_type=shop_order',
|
||||
'/wp-admin/admin.php?page=wc-admin&path=/customers',
|
||||
'/wp-admin/edit.php?post_type=shop_coupon&legacy_coupon_menu=1',
|
||||
'/wp-admin/admin.php?page=wc-admin&path=/marketing',
|
||||
'/wp-admin/admin.php?page=wc-reports',
|
||||
'/wp-admin/admin.php?page=wc-settings',
|
||||
'/wp-admin/admin.php?page=wc-status',
|
||||
'/wp-admin/admin.php?page=wc-admin&path=/extensions',
|
||||
'/wp-admin/edit.php?post_type=product',
|
||||
'/wp-admin/post-new.php?post_type=product',
|
||||
'/wp-admin/edit.php?post_type=product&page=product-reviews',
|
||||
'/wp-admin/edit.php?post_type=product&page=product_attributes',
|
||||
'/wp-admin/edit-tags.php?taxonomy=product_cat&post_type=product',
|
||||
'/wp-admin/edit-tags.php?taxonomy=product_tag&post_type=product',
|
||||
'/wp-admin/admin.php?page=wc-admin&path=/analytics/overview',
|
||||
'/wp-admin/admin.php?page=wc-admin',
|
||||
];
|
||||
|
||||
private Config $configHandler;
|
||||
private Helper $helper;
|
||||
private Rest $surveysRest;
|
||||
|
||||
public function __construct(
|
||||
Helper $helper,
|
||||
Config $configHandler,
|
||||
Rest $surveysRest
|
||||
) {
|
||||
$this->helper = $helper;
|
||||
$this->configHandler = $configHandler;
|
||||
$this->surveysRest = $surveysRest;
|
||||
}
|
||||
|
||||
public function isWoocommerceAdminPage(): bool
|
||||
{
|
||||
if (! isset($_SERVER['REQUEST_URI'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$currentUri = sanitize_text_field($_SERVER['REQUEST_URI']);
|
||||
|
||||
if (defined('DOING_AJAX') && \DOING_AJAX) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($currentUri) && strpos($currentUri, '/wp-json/') !== false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (self::WOOCOMMERCE_PAGES as $page) {
|
||||
if (strpos($currentUri, $page) !== false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isClientEligible(): bool
|
||||
{
|
||||
$transientRequestKey = self::IS_CLIENT_ELIGIBLE_TRANSIENT_REQUEST;
|
||||
$transientResponseKey = self::IS_CLIENT_ELIGIBLE_TRANSIENT_RESPONSE;
|
||||
$cachedEligibility = get_transient($transientResponseKey);
|
||||
|
||||
// Check if a request is already in progress
|
||||
if (get_transient('hts_eligible_request')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if transient response exists
|
||||
if ($cachedEligibility && ( $cachedEligibility === 'eligible' || $cachedEligibility === 'not_eligible' )) {
|
||||
return $cachedEligibility === 'eligible';
|
||||
}
|
||||
|
||||
// Attempt to set transient request
|
||||
if (! $this->helper->checkTransientEligibility($transientRequestKey, self::CACHE_THREE_HOURS)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
// Set transient flag to indicate request in progress
|
||||
set_transient('hts_eligible_request', 'in_progress', 60);
|
||||
|
||||
$isEligible = $this->surveysRest->isClientEligible();
|
||||
|
||||
// Clear the request transient flag
|
||||
delete_transient('hts_eligible_request');
|
||||
|
||||
if (has_action('litespeed_purge_all')) {
|
||||
do_action('litespeed_purge_all');
|
||||
}
|
||||
|
||||
if ($isEligible) {
|
||||
set_transient($transientResponseKey, 'eligible', self::CACHE_THREE_HOURS);
|
||||
|
||||
return $isEligible;
|
||||
}
|
||||
|
||||
set_transient($transientResponseKey, 'not_eligible', self::CACHE_THREE_HOURS);
|
||||
|
||||
return false;
|
||||
} catch (\Exception $exception) {
|
||||
$this->helper->errorLog('Error checking eligibility: ' . $exception->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function submitSurveyAnswers(array $answers, string $surveyId, string $surveyLocation): void
|
||||
{
|
||||
$data = [
|
||||
'identifier' => self::CLIENT_SURVEY_IDENTIFIER,
|
||||
'answers' => [
|
||||
[
|
||||
'question_slug' => self::LOCATION_SLUG,
|
||||
'answer' => $surveyLocation,
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
$answers = $this->addUserAnswers($data, $answers);
|
||||
|
||||
$success = $this->surveysRest->submitSurveyData($answers);
|
||||
|
||||
set_transient(self::SUBMITTED_SURVEY_TRANSIENT, true, self::TIME_24_HOURS);
|
||||
|
||||
if ($success) {
|
||||
delete_transient(self::IS_CLIENT_ELIGIBLE_TRANSIENT_RESPONSE);
|
||||
$settingKey = $surveyId . '_survey_completed';
|
||||
}
|
||||
|
||||
update_option('hostinger_' . $settingKey, true);
|
||||
wp_send_json('Survey completed');
|
||||
|
||||
if (has_action('litespeed_purge_all')) {
|
||||
do_action('litespeed_purge_all');
|
||||
}
|
||||
}
|
||||
|
||||
public function getSpecifiedSurvey(array $activeSurvey): array
|
||||
{
|
||||
$specifiedSurveyQuestions = [
|
||||
'pages' => [],
|
||||
'showQuestionNumbers' => 'off',
|
||||
'showTOC' => false,
|
||||
'pageNextText' => __('Next', 'hostinger-wp-surveys'),
|
||||
'pagePrevText' => __('Previous', 'hostinger-wp-surveys'),
|
||||
'completeText' => __('Submit', 'hostinger-wp-surveys'),
|
||||
'completedHtml' => __('Thank you for completing the survey !', 'hostinger-wp-surveys'),
|
||||
'requiredText' => '*',
|
||||
];
|
||||
|
||||
foreach ($activeSurvey['questions'] as $question) {
|
||||
$element = [
|
||||
'type' => $question['type'],
|
||||
'name' => $question['slug'],
|
||||
'title' => $question['question'],
|
||||
'requiredErrorText' => __('Response required.', 'hostinger-wp-surveys'),
|
||||
];
|
||||
|
||||
if ($question['slug'] == 'comment') {
|
||||
$element['maxLength'] = 250;
|
||||
}
|
||||
|
||||
if ($question['slug'] == 'score') {
|
||||
$element['rateMin'] = '1';
|
||||
$element['rateMax'] = '10';
|
||||
$element['minRateDescription'] = __('Poor', 'hostinger-wp-surveys');
|
||||
$element['maxRateDescription'] = __('Excellent', 'hostinger-wp-surveys');
|
||||
}
|
||||
|
||||
if ($question['isRequired']) {
|
||||
$element['isRequired'] = true;
|
||||
}
|
||||
|
||||
$questionData = [
|
||||
'name' => $question['slug'],
|
||||
'elements' => [ $element ],
|
||||
];
|
||||
|
||||
$specifiedSurveyQuestions['pages'][] = $questionData;
|
||||
}
|
||||
|
||||
return $specifiedSurveyQuestions;
|
||||
}
|
||||
|
||||
public static function getHostingerSurveys(): array
|
||||
{
|
||||
return apply_filters('hostinger_add_surveys', []);
|
||||
}
|
||||
|
||||
public function generateSurveyHtml(): string
|
||||
{
|
||||
$allSurveys = SurveyManager::getHostingerSurveys();
|
||||
|
||||
if (empty($allSurveys)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$activeSurvey = $this->getHighestPrioritySurvey($allSurveys);
|
||||
ob_start();
|
||||
?>
|
||||
<div class="hts-survey-wrapper"
|
||||
data-survey-id="<?php echo esc_attr($activeSurvey['id']) ?>"
|
||||
data-location="<?php echo esc_attr($activeSurvey['location']) ?>"
|
||||
data-surveys="<?php echo esc_attr(json_encode($this->getSpecifiedSurvey($activeSurvey))) ?>">
|
||||
<div class="close-btn">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="100" height="100" viewBox="0 0 24 24">
|
||||
<path d="M 4.9902344 3.9902344 A 1.0001 1.0001 0 0 0 4.2929688 5.7070312 L 10.585938 12 L 4.2929688 18.292969 A 1.0001 1.0001 0 1 0 5.7070312 19.707031 L 12 13.414062 L 18.292969 19.707031 A 1.0001 1.0001 0 1 0 19.707031 18.292969 L 13.414062 12 L 19.707031 5.7070312 A 1.0001 1.0001 0 0 0 18.980469 3.9902344 A 1.0001 1.0001 0 0 0 18.292969 4.2929688 L 12 10.585938 L 5.7070312 4.2929688 A 1.0001 1.0001 0 0 0 4.9902344 3.9902344 z"></path>
|
||||
</svg>
|
||||
</div>
|
||||
<div id="hostinger-feedback-survey"></div>
|
||||
<div id="hts-questionsLeft">
|
||||
<span id="hts-currentQuestion">1</span>
|
||||
<?php
|
||||
echo esc_html(
|
||||
__(
|
||||
'Question',
|
||||
'hostinger-wp-surveys'
|
||||
)
|
||||
);
|
||||
?>
|
||||
<?php echo esc_html(__('of ', 'hostinger-wp-surveys')); ?>
|
||||
<span id="hts-allQuestions"></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
public function defaultWoocommerceSurveyCompleted(): bool
|
||||
{
|
||||
$completedActions = get_option(self::CLIENT_WOO_COMPLETED_ACTIONS, []);
|
||||
$requiredCompletedActions = [ 'products', 'payments' ];
|
||||
|
||||
return empty(array_diff($requiredCompletedActions, $completedActions));
|
||||
}
|
||||
|
||||
public function getOldestProductDate(): int
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
$getProductDate = $wpdb->prepare(
|
||||
"
|
||||
SELECT MIN(post_date)
|
||||
FROM {$wpdb->posts}
|
||||
WHERE post_type = %s
|
||||
AND post_status = %s
|
||||
",
|
||||
'product',
|
||||
'publish'
|
||||
);
|
||||
|
||||
$oldestProductDate = $wpdb->get_var($getProductDate);
|
||||
|
||||
if ($oldestProductDate !== null) {
|
||||
$oldestProductDateTimestamp = strtotime($oldestProductDate);
|
||||
|
||||
if ($oldestProductDateTimestamp !== false) {
|
||||
return $oldestProductDateTimestamp;
|
||||
}
|
||||
}
|
||||
|
||||
return strtotime('-1 year');
|
||||
}
|
||||
|
||||
public function isTimeElapsed(string $firstLoginAt, int $timeInSeconds): bool
|
||||
{
|
||||
$currentTime = time();
|
||||
$timeElapsed = $currentTime - $timeInSeconds;
|
||||
|
||||
return $timeElapsed >= $firstLoginAt;
|
||||
}
|
||||
|
||||
public function activeSurveyHtml(): void
|
||||
{
|
||||
if (! did_action('activeSurvey')) {
|
||||
$survey_html = $this->generateSurveyHtml('');
|
||||
echo $survey_html;
|
||||
do_action('activeSurvey');
|
||||
}
|
||||
}
|
||||
|
||||
public static function addSurvey($surveyId, $scoreQuestion, $commentQuestion, $location, $priority)
|
||||
{
|
||||
$surveyData = [
|
||||
'id' => $surveyId,
|
||||
'questions' => [
|
||||
[
|
||||
'type' => 'rating',
|
||||
'slug' => 'score',
|
||||
'question' => $scoreQuestion,
|
||||
'isRequired' => true
|
||||
],
|
||||
[
|
||||
'type' => 'comment',
|
||||
'slug' => 'comment',
|
||||
'question' => $commentQuestion,
|
||||
'isRequired' => false
|
||||
],
|
||||
],
|
||||
'location' => $location,
|
||||
'priority' => $priority,
|
||||
];
|
||||
|
||||
$surveys[] = $surveyData;
|
||||
|
||||
return $surveys;
|
||||
}
|
||||
|
||||
public function getHighestPrioritySurvey(array $allSurveys): array
|
||||
{
|
||||
$surveys = array_merge([], ...$allSurveys);
|
||||
|
||||
return array_reduce($surveys, function ($highestPrioritySurvey, $currentSurvey) {
|
||||
return ( ! isset($highestPrioritySurvey['priority']) ||
|
||||
( isset($currentSurvey['priority']) && $currentSurvey['priority'] > $highestPrioritySurvey['priority'] ) )
|
||||
? $currentSurvey : $highestPrioritySurvey;
|
||||
}, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a specific survey is not completed
|
||||
* @param string $surveyId
|
||||
* @return bool
|
||||
*/
|
||||
public function isSurveyNotCompleted(string $surveyId): bool
|
||||
{
|
||||
$optionKey = 'hostinger_' . $surveyId . '_survey_completed';
|
||||
$notCompleted = ! get_option($optionKey, '');
|
||||
return $notCompleted;
|
||||
}
|
||||
|
||||
private function addUserAnswers(array $data, array $answers): array
|
||||
{
|
||||
foreach ($answers as $answerSlug => $answer) {
|
||||
$data['answers'][] = [
|
||||
'question_slug' => $answerSlug,
|
||||
'answer' => $answer,
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function isSurveyHidden(): bool
|
||||
{
|
||||
$surveyVisibility = get_transient(self::HIDE_SURVEY_TRANSIENT);
|
||||
return $surveyVisibility !== false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user