Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into enhance/repeat-f…
Browse files Browse the repository at this point in the history
…ield-enhancement
  • Loading branch information
sapayth committed Aug 29, 2024
2 parents d7678ac + 49a2c9f commit 3680861
Show file tree
Hide file tree
Showing 211 changed files with 26,962 additions and 20,999 deletions.
6 changes: 2 additions & 4 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
.gitignore export-ignore
.jshintrc export-ignore
.php_cs.dist export-ignore
.svnignore export-ignore
.php_cs export-ignore
.github export-ignore
Gruntfile.js export-ignore
appsero.json export-ignore
composer.json export-ignore
composer.lock export-ignore
docs.md export-ignore
package-lock.json export-ignore
package.json export-ignore
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Plugin asset/readme update
on:
push:
branches:
- trunk
jobs:
trunk:
name: Push to trunk
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: WordPress.org plugin asset/readme update
uses: 10up/action-wordpress-plugin-asset-update@stable
env:
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
2 changes: 1 addition & 1 deletion .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.3"
php-version: "7.4"
coverage: none
tools: composer, cs2pr

Expand Down
4 changes: 2 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = function(grunt) {
files: {
'<%= dirs.css %>/wpuf-form-builder.css': ['admin/form-builder/assets/less/form-builder.less'],
'<%= dirs.css %>/admin.css': ['<%= dirs.less %>/admin.less'],
'<%= dirs.css %>/admin/whats-new.css': ['<%= dirs.less %>/whats-new.less'],
'<%= dirs.css %>/registration-forms.css': ['<%= dirs.less %>/registration-forms.less']
}
}
Expand Down Expand Up @@ -138,7 +139,6 @@ module.exports = function(grunt) {
'!**/readme.md',
'!**/docs.md',
'!**/*~',
'!vendor/**',
'!**/log.txt',
'!**/package-lock.json',
'!**/appsero.json',
Expand Down Expand Up @@ -218,7 +218,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks( 'grunt-notify' );
grunt.loadNpmTasks( 'grunt-wp-readme-to-markdown' );

grunt.registerTask( 'default', [ 'less', 'concat' ] );
grunt.registerTask( 'default', [ 'less', 'concat', 'uglify', 'i18n' ] );

// file auto generation
grunt.registerTask( 'i18n', [ 'makepot' ] );
Expand Down
102 changes: 40 additions & 62 deletions lib/appsero/Client.php → Lib/Appsero/Client.php
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
namespace Appsero;

namespace WeDevs\Wpuf\Lib\Appsero;

/**
* Appsero Client
Expand All @@ -13,7 +14,7 @@ class Client {
*
* @var string
*/
public $version = '1.2.2';
public $version = '1.3.0';

/**
* Hash identifier of the plugin
Expand All @@ -31,6 +32,7 @@ class Client {

/**
* The plugin/theme file path
*
* @example .../wp-content/plugins/test-slug/test-slug.php
*
* @var string
Expand All @@ -39,6 +41,7 @@ class Client {

/**
* Main plugin file
*
* @example test-slug/test-slug.php
*
* @var string
Expand All @@ -47,6 +50,7 @@ class Client {

/**
* Slug of the plugin
*
* @example test-slug
*
* @var string
Expand All @@ -68,7 +72,7 @@ class Client {
public $type;

/**
* textdomain
* Textdomain
*
* @var string
*/
Expand All @@ -79,14 +83,7 @@ class Client {
*
* @var object
*/
private $insights;

/**
* The Object of Updater Class
*
* @var object
*/
private $updater;
public $insights;

/**
* The Object of License Class
Expand All @@ -95,12 +92,12 @@ class Client {
*/
private $license;

/**
/**
* Initialize the class
*
* @param string $hash hash of the plugin
* @param string $name readable name of the plugin
* @param string $file main plugin file path
* @param string $hash hash of the plugin
* @param string $name readable name of the plugin
* @param string $file main plugin file path
*/
public function __construct( $hash, $name, $file ) {
$this->hash = $hash;
Expand All @@ -116,8 +113,7 @@ public function __construct( $hash, $name, $file ) {
* @return Appsero\Insights
*/
public function insights() {

if ( ! class_exists( __NAMESPACE__ . '\Insights') ) {
if ( ! class_exists( __NAMESPACE__ . '\Insights' ) ) {
require_once __DIR__ . '/Insights.php';
}

Expand All @@ -131,35 +127,13 @@ public function insights() {
return $this->insights;
}

/**
* Initialize plugin/theme updater
*
* @return Appsero\Updater
*/
public function updater() {

if ( ! class_exists( __NAMESPACE__ . '\Updater') ) {
require_once __DIR__ . '/Updater.php';
}

// if already instantiated, return the cached one
if ( $this->updater ) {
return $this->updater;
}

$this->updater = new Updater( $this );

return $this->updater;
}

/**
* Initialize license checker
*
* @return Appsero\License
*/
public function license() {

if ( ! class_exists( __NAMESPACE__ . '\License') ) {
if ( ! class_exists( __NAMESPACE__ . '\License' ) ) {
require_once __DIR__ . '/License.php';
}

Expand Down Expand Up @@ -190,27 +164,26 @@ public function endpoint() {
* @return void
*/
protected function set_basename_and_slug() {

if ( strpos( $this->file, WP_CONTENT_DIR . '/themes/' ) === false ) {
$this->basename = plugin_basename( $this->file );

list( $this->slug, $mainfile) = explode( '/', $this->basename );
list( $this->slug, $mainfile ) = explode( '/', $this->basename );

require_once ABSPATH . 'wp-admin/includes/plugin.php';

$plugin_data = get_plugin_data( $this->file );

$this->project_version = $plugin_data['Version'];
$this->type = 'plugin';
$this->type = 'plugin';
} else {
$this->basename = str_replace( WP_CONTENT_DIR . '/themes/', '', $this->file );

list( $this->slug, $mainfile) = explode( '/', $this->basename );
list( $this->slug, $mainfile ) = explode( '/', $this->basename );

$theme = wp_get_theme( $this->slug );

$this->project_version = $theme->version;
$this->type = 'theme';
$this->type = 'theme';
}

$this->textdomain = $this->slug;
Expand All @@ -219,54 +192,59 @@ protected function set_basename_and_slug() {
/**
* Send request to remote endpoint
*
* @param array $params
* @param string $route
* @param array $params
* @param string $route
*
* @return array|WP_Error Array of results including HTTP headers or WP_Error if the request failed.
* @return array|WP_Error array of results including HTTP headers or WP_Error if the request failed
*/
public function send_request( $params, $route, $blocking = false ) {
$url = $this->endpoint() . $route;

$headers = array(
$headers = [
'user-agent' => 'Appsero/' . md5( esc_url( home_url() ) ) . ';',
'Accept' => 'application/json',
];

$response = wp_remote_post(
$url,
[
'method' => 'POST',
'timeout' => 30,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => $blocking,
'headers' => $headers,
'body' => array_merge( $params, [ 'client' => $this->version ] ),
'cookies' => [],
]
);

$response = wp_remote_post( $url, array(
'method' => 'POST',
'timeout' => 30,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => $blocking,
'headers' => $headers,
'body' => array_merge( $params, array( 'client' => $this->version ) ),
'cookies' => array()
) );

return $response;
}

/**
* Check if the current server is localhost
*
* @return boolean
* @return bool
*/
public function is_local_server() {
$is_local = in_array( $_SERVER['REMOTE_ADDR'], array( '127.0.0.1', '::1' ) );
$is_local = isset( $_SERVER['REMOTE_ADDR'] ) && in_array( $_SERVER['REMOTE_ADDR'], [ '127.0.0.1', '::1' ], true );

return apply_filters( 'appsero_is_local', $is_local );
}

/**
* Translate function _e()
*/
// phpcs:ignore
public function _etrans( $text ) {
call_user_func( '_e', $text, $this->textdomain );
}

/**
* Translate function __()
*/
// phpcs:ignore
public function __trans( $text ) {
return call_user_func( '__', $text, $this->textdomain );
}
Expand Down
Loading

0 comments on commit 3680861

Please sign in to comment.