Skip to content

Commit

Permalink
Merge pull request #214 from pluginever/fix/213
Browse files Browse the repository at this point in the history
Fix #213
  • Loading branch information
kawsarahmedr authored Aug 25, 2024
2 parents 0bf5c30 + 3d27a0c commit 02f3552
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 34 deletions.
12 changes: 8 additions & 4 deletions i18n/languages/wp-content-pilot.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# This file is distributed under the GPL v2 or later.
msgid ""
msgstr ""
"Project-Id-Version: WP Content Pilot 1.3.6\n"
"Project-Id-Version: WP Content Pilot 2.0.0\n"
"Report-Msgid-Bugs-To: https://pluginever.com/support/\n"
"POT-Creation-Date: 2024-08-14 09:56:38+00:00\n"
"POT-Creation-Date: 2024-08-21 09:50:06+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
Expand Down Expand Up @@ -2952,8 +2952,8 @@ msgstr ""
msgid "WP Content Pilot"
msgstr ""

#. Author URI of the plugin/theme
msgid "https://pluginever.com"
#. Plugin URI of the plugin/theme
msgid "https://wpcontentpilot.com"
msgstr ""

#. Description of the plugin/theme
Expand All @@ -2966,6 +2966,10 @@ msgstr ""
msgid "PluginEver"
msgstr ""

#. Author URI of the plugin/theme
msgid "https://pluginever.com"
msgstr ""

#: includes/post-types.php:21
msgctxt "campaign post type name"
msgid "Campaigns"
Expand Down
73 changes: 50 additions & 23 deletions includes/admin/class-wpcp-admin.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<?php
defined( 'ABSPATH' ) || exit();

/**
* Class WPCP_Admin
*
* @since 1.0.0
* @package WPContentPilot
*/
class WPCP_Admin {

/**
Expand All @@ -9,9 +15,11 @@ class WPCP_Admin {
* @var WPCP_Admin
* @since 1.0.0
*/
protected static $_instance = null;
protected static $instance = null;

/**
* WPCP_Admin constructor.
*
* @since 1.2.0
* WPCP_Admin constructor.
*/
Expand All @@ -21,20 +29,24 @@ public function __construct() {
}

/**
* Includes
* Includes.
*
* @since 1.2.0
* @return void
*/
public function includes() {
require_once( dirname( __FILE__ ) . '/admin-functions.php' );
require_once ( dirname( __FILE__ ). '/class-wpcp-updater.php');
require_once( dirname( __FILE__ ) . '/class-settings-framework.php' );
require_once( dirname( __FILE__ ) . '/class-wpcp-settings.php' );
require_once( dirname( __FILE__ ) . '/metabox-functions.php' );
require_once __DIR__ . '/admin-functions.php';
require_once __DIR__ . '/class-wpcp-updater.php';
require_once __DIR__ . '/class-settings-framework.php';
require_once __DIR__ . '/class-wpcp-settings.php';
require_once __DIR__ . '/metabox-functions.php';
}

/**
* Init hooks
* Init hooks.
*
* @since 1.2.0
* @return void
*/
public function init_hooks() {
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
Expand All @@ -45,32 +57,42 @@ public function init_hooks() {
}

/**
* Admin menu.
*
* @since 1.2.0
* @return void
*/
function admin_menu() {
public function admin_menu() {
$hook = 'edit.php?post_type=wp_content_pilot';
add_submenu_page( $hook, __( 'Status', 'wp-content-pilot' ), __( 'Status', 'wp-content-pilot' ), 'edit_others_posts', 'wpcp-status', array( $this, 'status_page' ) );
add_submenu_page( $hook, __( 'Logs', 'wp-content-pilot' ), __( 'Logs', 'wp-content-pilot' ), 'edit_others_posts', 'wpcp-logs', array( $this, 'logs_page' ) );
}

/**
* status page
* Status page.
*
* @since 1.2.0
* @return void
*/
public function status_page() {
wpcp_get_views( 'page/status-page.php' );
}

/**
* Logs page
* Logs page.
*
* @since 1.2.0
* @return void
*/
public function logs_page() {
wpcp_get_views( 'page/logs-page.php' );
}

/**
* Get pro link.
*
* @since 1.2.0
* @return void
*/
public function get_pro_link() {
if ( ! defined( 'WPCP_PRO_VERSION' ) ) {
Expand All @@ -86,21 +108,25 @@ public function get_pro_link() {
}

/**
* Redirect to pro page.
*
* @since 1.2.0
* @return void
*/
public function go_pro_redirect() {
wp_verify_nonce( '_nonce' );

if ( isset( $_GET['page'] ) && 'go_wpcp_pro' === $_GET['page'] ) {
wp_redirect( 'https://pluginever.com/plugins/wp-content-pilot-pro/?utm_source=wp-menu&utm_campaign=gopro&utm_medium=wp-dash' );
wp_safe_redirect( 'https://pluginever.com/plugins/wp-content-pilot-pro/?utm_source=wp-menu&utm_campaign=gopro&utm_medium=wp-dash' );
die;
}
}

/**
* Do plugin upgrades
* Do plugin upgrades.
*
* @return void
* @since 1.0.0
*
* @return void
*/
public function plugin_upgrades() {
if ( ! current_user_can( 'manage_options' ) ) {
Expand All @@ -113,20 +139,21 @@ public function plugin_upgrades() {
}

/**
* 5 Star Rating banner.
* 5-Star Rating banner.
*
* since 1.2.0
* @since 1.2.0
* @return string
*/
public function admin_footer_note(){
public function admin_footer_note() {
$screen = get_current_screen();

if ( 'wp_content_pilot' == $screen->post_type ) {
if ( 'wp_content_pilot' === $screen->post_type ) {
$star_url = 'https://wordpress.org/support/plugin/wp-content-pilot/reviews/?filter=5#new-post';
$text = sprintf( __( 'If you like <strong>WP Content Pilot</strong> please leave us a <a href="%s" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a> rating. Your Review is very important to us as it helps us to grow more.', 'wp-content-pilot' ), $star_url );
$text = sprintf( /* translators: %s: 5 star rating url */ __( 'If you like <strong>WP Content Pilot</strong> please leave us a <a href="%s" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a> rating. Your Review is very important to us as it helps us to grow more.', 'wp-content-pilot' ), $star_url );
return $text;
}

return '';
}

/**
Expand All @@ -139,11 +166,11 @@ public function admin_footer_note(){
* @static
*/
public static function instance() {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self();
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}

return self::$_instance;
return self::$instance;
}
}

Expand Down
15 changes: 12 additions & 3 deletions includes/class-wpcp-module.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ public function process_campaign( $campaign_id, $source = null, $user = 'cron' )
if ( 'clickbank' === $campaign_type || 'instagram' === $campaign_type || 'soundcloud' === $campaign_type ) {
$attachment_id = $article['attachment_id'];
} else {
wpcp_logger()->info( __( 'Downloading image', 'wp-content-pilot' ), $campaign_id );
$attachment_id = wpcp_download_image( html_entity_decode( $article['image_url'] ) );
}
if ( $attachment_id ) {
Expand Down Expand Up @@ -470,9 +471,17 @@ public function process_campaign( $campaign_id, $source = null, $user = 'cron' )
// Updating post meta if the campaign post type selected as product.
if( 'product' === $post_type ) {
wpcp_logger()->info( __( 'Updating product price, regular price & sale price.', 'wp-content-pilot' ), $campaign_id );
update_post_meta( $post_id, '_price', floatval( $article['_regular_price'] ) );
update_post_meta( $post_id, '_regular_price', floatval( $article['_regular_price'] ) );
update_post_meta( $post_id, '_sale_price', floatval( $article['_sale_price'] ) );

// Update product price & regular price & sale price if the campaign post type selected as product.
// Check if _sale_price is empty then set _price & _regular_price only otherwise set _price, _regular_price & _sale_price.
if( empty( $article['_sale_price'] ) ) {
update_post_meta( $post_id, '_price', floatval( $article['_regular_price'] ) );
update_post_meta( $post_id, '_regular_price', floatval( $article['_regular_price'] ) );
} else {
update_post_meta( $post_id, '_price', floatval( $article['_sale_price'] ) );
update_post_meta( $post_id, '_regular_price', floatval( $article['_regular_price'] ) );
update_post_meta( $post_id, '_sale_price', floatval( $article['_sale_price'] ) );
}
}

// Save campaign data.
Expand Down
9 changes: 9 additions & 0 deletions includes/core-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,21 @@ function wpcp_download_image( $url, $description = '' ) {
'image/jpeg',
'image/gif',
);

// If the image type is equal to : image/jpeg;charset=ISO-8859-1 the only take image/jpeg
if ( ! in_array( $type, $types, true ) && strpos( $type, ';' ) !== false ) {
$type = explode( ';', $type );
$type = $type[0];
}

$file_ext = array(
'image/png' => '.png',
'image/jpeg' => '.jpg',
'image/gif' => '.gif',
);

if ( is_wp_error( $get ) || ! isset( $type ) || ( ! in_array( $type, $types, true ) ) ) {
wpcp_logger()->error( __( 'Failed to download image', 'wp-content-pilot' ) );
return false;
}
$file_name = basename( $url );
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
if ( isset( $wpcp_settings['uninstall_on_delete'] ) && 'on' === $wpcp_settings['uninstall_on_delete'] ) {
global $wpdb;
// Remove all database tables.
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . 'wpcp_links' );
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . 'wpcp_logs' );
$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'wpcp_links' );
$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'wpcp_logs' );

/** Cleanup Cron Events */
wp_clear_scheduled_hook( 'wpcp_per_minute_scheduled_events' );
Expand Down

0 comments on commit 02f3552

Please sign in to comment.