Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: composer install --prefer-dist --no-progress --quiet
continue-on-error: true
- name: Run PHPCS
run: composer run lint
run: composer run lint:errors
continue-on-error: false

php-unit:
Expand Down
2 changes: 1 addition & 1 deletion class-rop-autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static function loader( $class_name ) {
$filename = 'class-' . str_replace( '_', '-', strtolower( $class_name ) ) . static::$file_ext;
foreach ( static::$file_iterator as $file ) {
if ( strtolower( $file->getFileName() ) === strtolower( $filename ) && is_readable( $file->getPathName() ) ) {
require( $file->getPathName() );
require $file->getPathName();
return true;
}
}
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"build": "sh bin/dist.sh",
"test": "vendor/bin/phpunit",
"lint": "vendor/bin/phpcs --standard=phpcs.xml --extensions=php -s",
"lint:errors": "phpcs --standard=phpcs.xml -n",
"format": "vendor/bin/phpcbf --standard=phpcs.xml --report-summary --report-source",
"phpstan": "phpstan",
"phpstan:generate:baseline": "phpstan --generate-baseline"
Expand Down Expand Up @@ -52,11 +53,11 @@
"installer-disable": true
},
"require-dev": {
"wp-coding-standards/wpcs": "^2.3",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2",
"wp-coding-standards/wpcs": "^3.2",
"dealerdirect/phpcodesniffer-composer-installer": "^1.1.2",
"phpunit/phpunit": "9.*",
"yoast/phpunit-polyfills": "^2.0",
"codeinwp/phpcs-ruleset": "dev-main",
"automattic/vipwpcs": "^3.0",
"phpstan/phpstan": "^2.1",
"szepeviktor/phpstan-wordpress": "^2.0"
},
Expand Down
664 changes: 303 additions & 361 deletions composer.lock

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions cron-system/class-rop-cron-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Rop_Cron_Core {
/**
* Rop_Cron_Core constructor.
*/
function __construct() {
public function __construct() {

/**
* Register to ROP Cron the share start.
Expand All @@ -53,7 +53,6 @@ function __construct() {
* Register local end-points used by ROP Cron Service.
*/
add_action( 'init', array( &$this, 'init_endpoint_items' ) );

}

/**
Expand Down Expand Up @@ -153,7 +152,5 @@ public function server_register_client() {
'request_path' => ':register_account:',
);
$call_response = $request_call->create_call_process( $arguments );

}

}
91 changes: 45 additions & 46 deletions cron-system/includes/class-debug-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

namespace RopCronSystem\Pages;


use RopCronSystem\Curl_Helpers\Rop_Curl_Methods;
use RopCronSystem\ROP_Helpers\Rop_Helpers;

Expand All @@ -27,7 +26,7 @@ class Debug_Page {
*
* Debug_Page constructor.
*/
function __construct() {
public function __construct() {
add_action( 'admin_menu', array( &$this, 'debug_page_menu' ) );

add_action( 'admin_enqueue_scripts', array( &$this, 'load_custom_wp_admin_style' ) );
Expand Down Expand Up @@ -163,105 +162,105 @@ public function rop_service_debug() {
}

?>
<div class="wrap" id="rop-debug-table">
<h1><?php _e( 'Debug Info: ', 'tweet-old-post' ); ?></h1>
<div class="wrap" id="rop-debug-table">
<h1><?php esc_html_e( 'Debug Info: ', 'tweet-old-post' ); ?></h1>
<br/>

<table>
<tr>
<td valign="top"><?php _e( 'PHP Version: ', 'tweet-old-post' ); ?></td>
<tr>
<td valign="top"><?php esc_html_e( 'PHP Version: ', 'tweet-old-post' ); ?></td>
<td>
<?php
echo $version;
echo esc_html( $version );

if ( version_compare( $version, '7.0.0', '<' ) ) {
echo ' <strong style="color:darkred">' . __( 'PHP 7 is recommended', 'tweet-old-post' ) . '</strong>';
echo ' <strong style="color:darkred">' . esc_html__( 'PHP 7 is recommended', 'tweet-old-post' ) . '</strong>';
}

?>
<br/>
<br/>
</td>
</tr>
<tr>
<td valign="top"><?php _e( 'cURL Info: ', 'tweet-old-post' ); ?></td>
</tr>
<tr>
<td valign="top"><?php esc_html_e( 'cURL Info: ', 'tweet-old-post' ); ?></td>
<td>
<?php
if ( ! empty( $curl_version ) ) {
echo 'version: ' . $curl_version['version'] . ' (' . $curl_version['version_number'] . ') ' . '<br/>';
echo 'libz version: ' . $curl_version['libz_version'] . '<br/>';
echo 'OpenSSL: ' . $curl_version['ssl_version'] . '<br/>';
echo 'version: ' . esc_html( $curl_version['version'] ) . ' (' . esc_html( $curl_version['version_number'] ) . ')<br/>';
echo 'libz version: ' . esc_html( $curl_version['libz_version'] ) . '<br/>';
echo 'OpenSSL: ' . esc_html( $curl_version['ssl_version'] ) . '<br/>';
echo '<strong>Protocols</strong>: <br/>'; // . implode( ',', $curl_version['protocols'] ) . '<br/>';

echo 'HTTP: ' . ( ( in_array( 'http', $curl_version['protocols'] ) ) ? '<span style="color:darkgreen">&#10004;</span>' : '<span style="color:darkred">&#10006;</span>' ) . '<br/>';
echo 'HTTPS: ' . ( ( in_array( 'https', $curl_version['protocols'] ) ) ? '<span style="color:darkgreen">&#10004;</span>' : '<span style="color:darkred">&#10006;</span>' ) . '<br/>';

} else {
echo '<strong style="color:darkred">' . __( 'No version of CURL detected.', 'tweet-old-post' ) . '</strong>';
echo '<strong style="color:darkred">' . esc_html__( 'No version of CURL detected.', 'tweet-old-post' ) . '</strong>';
}
?>
<br/>
<br/>
</td>
</tr>
<tr>
<td valign="top"><?php _e( 'Check connection with<br/>Revive Social Cron SyStem: ', 'tweet-old-post' ); ?></td>
</tr>
<tr>
<td valign="top"><?php esc_html_e( 'Check connection with<br/>Revive Social Cron SyStem: ', 'tweet-old-post' ); ?></td>
<td>
<?php _e( 'WordPress -> Server:', 'tweet-old-post' ); ?>
<span id="server_responded">N/A</span>
<br/>
<?php _e( 'Server -> WordPress:', 'tweet-old-post' ); ?>
<span id="website_responded">N/A</span>
<br/>
<br/>
<input type="button" value="<?php _e( 'Check connection', 'tweet-old-post' ); ?>" id="rop_conection_check"/>
<?php esc_html_e( 'WordPress -> Server:', 'tweet-old-post' ); ?>
<span id="server_responded">N/A</span>
<br/>
<?php esc_html_e( 'Server -> WordPress:', 'tweet-old-post' ); ?>
<span id="website_responded">N/A</span>
<br/>
<br/>
<input type="button" value="<?php esc_attr_e( 'Check connection', 'tweet-old-post' ); ?>" id="rop_conection_check"/>
</td>
</tr>
</tr>
</table>

<br/>
<hr/>
<br/>

<table>
<tr>
<tr>
<td>
<input type="button" value="<?php _e( 'Delete Remote Cron Service Data', 'tweet-old-post' ); ?>" id="rop_remove_account"/>
<span id="ajax_rop_remove_account">
<input type="button" value="<?php esc_attr_e( 'Delete Remote Cron Service Data', 'tweet-old-post' ); ?>" id="rop_remove_account"/>
<span id="ajax_rop_remove_account">

</span>
</span>

<p>
<p>
<em>
<?php
$labels = new \Rop_I18n();
echo $labels::get_labels( 'cron_system.delete_cron_service_account_info' );
echo esc_html( $labels::get_labels( 'cron_system.delete_cron_service_account_info' ) );
?>
</em>
</p>
</p>
</td>
</tr>
</tr>
</table>

<table>
<tr>
<tr>
<td>
<input type="button" value="<?php _e( 'Clear Local Cron Data', 'tweet-old-post' ); ?>" id="rop_clear_local"/>
<span id="ajax_rop_clear_local">
<input type="button" value="<?php esc_attr_e( 'Clear Local Cron Data', 'tweet-old-post' ); ?>" id="rop_clear_local"/>
<span id="ajax_rop_clear_local">

</span>
</span>

<p>
<p>
<em>
<?php
echo $labels::get_labels( 'cron_system.clear_local_cron_info' );
echo esc_html( $labels::get_labels( 'cron_system.clear_local_cron_info' ) );
?>
</em>
</p>
</p>
</td>
</tr>
</tr>
</table>


</div>
</div>
<?php
}
}
39 changes: 17 additions & 22 deletions cron-system/includes/class-rop-curl-methods.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Rop_Curl_Methods {
*
* Rop_Curl_Methods constructor.
*/
function __construct() {
public function __construct() {
$this->error = new Rop_Exception_Handler();
$this->logger = new Rop_Logger();
}
Expand Down Expand Up @@ -115,9 +115,10 @@ public function create_call_process( $args = array() ) {

if ( 'post' === strtolower( $args['type'] ) ) {

if ( ':delete_account:' !== $args['request_path'] ) {
// unset( $args['remove_location'] );
}
// if ( ':delete_account:' !== $args['request_path'] ) {
// This condition is intentionally left for future use
// when we might need to handle specific request paths differently
// }

$post_fields = array();

Expand All @@ -126,35 +127,32 @@ public function create_call_process( $args = array() ) {
$this->server_url = self::SERVER_URL . $this->server_paths[ $args['request_path'] ];
$this->connection = curl_init( $this->server_url );
$this->register_to_top_server();
} else {
} elseif ( empty( $token ) && ':delete_account:' !== $args['request_path'] ) {

if ( empty( $token ) && ':delete_account:' !== $args['request_path'] ) {
$this->server_url = self::SERVER_URL . $this->server_paths[':register_account:'];
$this->connection = curl_init( $this->server_url );

// If the request comes with "Stop cron" action, there's no need for it in account registration.
if ( ':disable_account:' === $args['request_path'] ) {
$args = array();
}
if ( ':disable_account:' === $args['request_path'] ) {
$args = array();
}

$this->register_to_top_server( $args );
} else {

$this->server_url = self::SERVER_URL . $this->server_paths[ $args['request_path'] ];
$this->connection = curl_init( $this->server_url );
} else {

if ( isset( $args['time_to_share'] ) && ! empty( $args['time_to_share'] ) ) {
$post_fields = array( 'next_ping' => $args['time_to_share'] );
$this->server_url = self::SERVER_URL . $this->server_paths[ $args['request_path'] ];
$this->connection = curl_init( $this->server_url );

}
if ( isset( $args['time_to_share'] ) && ! empty( $args['time_to_share'] ) ) {
$post_fields = array( 'next_ping' => $args['time_to_share'] );

return $this->request_type_post( $post_fields, $args['request_path'] );
}

return $this->request_type_post( $post_fields, $args['request_path'] );
}
}

return true;

}


Expand Down Expand Up @@ -404,7 +402,6 @@ private function register_to_top_server( $callback_param = array() ) {

return false;
}

}

/**
Expand Down Expand Up @@ -447,7 +444,6 @@ private function fetch_attach_auth_token( $custom_value = '', $post_data = '' )

return false;
}

}


Expand Down Expand Up @@ -482,15 +478,14 @@ private function create_register_data() {
$url_encode_data = http_build_query( $account_data );

return base64_encode( $url_encode_data );

}

/**
* Destruct magic function, un-sets the cURL connection resource.
*
* @since 8.5.5
*/
function __destruct() {
public function __destruct() {
unset( $this->connection );
}
}
13 changes: 5 additions & 8 deletions cron-system/includes/class-rop-helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace RopCronSystem\ROP_Helpers;


use Rop_Exception_Handler;
use Rop_Logger;
use Rop_Scheduler_Model;
Expand Down Expand Up @@ -31,7 +30,7 @@ class Rop_Helpers {
* @static
* @since 8.5.5
*/
static public function extract_time_to_share() {
public static function extract_time_to_share() {
// dates are stored into variable "rop_schedules_data".
$scheduler = new Rop_Scheduler_Model();

Expand Down Expand Up @@ -82,7 +81,7 @@ static public function extract_time_to_share() {
* @static
* @since 8.5.5
*/
static public function local_timezone() {
public static function local_timezone() {

// WordPress saves timezone in 2 different variables.
// If it's UTC the option name is "".
Expand All @@ -107,7 +106,7 @@ static public function local_timezone() {
* @access public
* @static
*/
static public function apache_request_headers() {
public static function apache_request_headers() {
$headers_output = array();
$headers_output_return = array();
if ( ! function_exists( 'apache_request_headers' ) ) {
Expand Down Expand Up @@ -140,7 +139,7 @@ static public function apache_request_headers() {
*
* @return false|string
*/
static public function openssl_random_pseudo_bytes( $count = 40 ) {
public static function openssl_random_pseudo_bytes( $count = 40 ) {
if ( function_exists( 'openssl_random_pseudo_bytes' ) ) {
return openssl_random_pseudo_bytes( $count );
} else {
Expand Down Expand Up @@ -169,7 +168,7 @@ static public function openssl_random_pseudo_bytes( $count = 40 ) {
*
* @return bool|string
*/
static public function custom_curl_post_request( $url = '', $post_arguments = array() ) {
public static function custom_curl_post_request( $url = '', $post_arguments = array() ) {

$logger = new Rop_Logger();

Expand Down Expand Up @@ -284,5 +283,3 @@ static public function custom_curl_post_request( $url = '', $post_arguments = ar
return $server_response_body;
}
}


Loading
Loading