Skip to content

Commit

Permalink
Merge pull request #124 from sendsmaily/release/1.9.2
Browse files Browse the repository at this point in the history
Release 1.9.2
  • Loading branch information
kaittodesk authored Jun 17, 2022
2 parents 00cca7f + 8c8e183 commit 226e666
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 58 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

### 1.9.2
- Generating RSS feed URL takes account permalinks enabled state [[#122](https://github.com/sendsmaily/smaily-woocommerce-plugin/pull/122)]
- RSS feed template is rendered at a later stage to ensure RSS is rendered [[#122](https://github.com/sendsmaily/smaily-woocommerce-plugin/pull/122)]
- Use common practice on formatting User-Agent string [[#123](https://github.com/sendsmaily/smaily-woocommerce-plugin/pull/123)]

### 1.9.1
- Update user manual links. [[#116](https://github.com/sendsmaily/smaily-woocommerce-plugin/pull/116)]

Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,6 @@ Try re-saving permalinks.
Go to Admin panel -> Settings -> Permalinks.
Scroll to bottom and click "Save Changes" without modifing anything

### How can I filter RSS-feed output by category and limit results?

You can access RSS feed by visiting ulr `store_url/smaily-rss-feed` and you can add parameters (category and limit) by appending them to URL. For example `store_url/smaily-rss-feed?category=tshirts&limit=3`. Regular RSS-feed shows 50 last updated products.

### Where I can find data-log for Cron?

Cron update data-log is stored in the root folder of Smaily plugin, inside "smaily-cron.txt" file.
Expand Down
17 changes: 12 additions & 5 deletions inc/Api/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,13 @@ public function save_api_information() {
}

// Verify API credentials actually work.
$useragent = 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ) . '; WooCommerce/' . WC_VERSION . '; smaily-for-woocommerce/' . SMAILY_PLUGIN_VERSION;
$api_call = wp_remote_get(
$api_call = wp_remote_get(
'https://' . $api_credentials['subdomain'] . '.sendsmaily.net/api/workflows.php?trigger_type=form_submitted',
array(
'headers' => array(
'Authorization' => 'Basic ' . base64_encode( $api_credentials['username'] . ':' . $api_credentials['password'] ),
),
'user-agent' => $useragent,
'user-agent' => $this->get_user_agent(),
)
);

Expand Down Expand Up @@ -248,8 +247,7 @@ public static function ApiCall( $endpoint, $params = '', array $data = array(),
$data = array_merge( $data, array( 'headers' => array( 'Authorization' => 'Basic ' . base64_encode( $result['username'] . ':' . $result['password'] ) ) ) );

// Add User-Agent string to data of request.
$useragent = 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ) . '; WooCommerce/' . WC_VERSION . '; smaily-for-woocommerce/' . SMAILY_PLUGIN_VERSION;
$data = array_merge( $data, array( 'user-agent' => $useragent ) );
$data = array_merge( $data, array( 'user-agent' => self::get_user_agent() ) );

// API call with GET request.
if ( $method === 'GET' ) {
Expand Down Expand Up @@ -489,4 +487,13 @@ protected function collect_rss_data( array $payload ) {

return $rss;
}

/**
* Compile User-Agent header value for API requests.
*
* @return string
*/
protected static function get_user_agent() {
return 'smaily-for-woocommerce/' . SMAILY_PLUGIN_VERSION . ' (WordPress/' . get_bloginfo( 'version' ) . '; WooCommerce/' . WC_VERSION . '; +' . get_bloginfo( 'url' ) . ')';
}
}
17 changes: 12 additions & 5 deletions inc/Base/DataHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,13 @@ public static function get_woocommerce_categories_list() {
* @param int $rss_limit Limit of products.
* @param string $rss_order_by Order products by.
* @param string $rss_order ASC/DESC order
* @return string RSS URL e.g. example.com/smaily-rss-feed?category=uncategorized&limit=250
* @return string
*/
public static function make_rss_feed_url( $rss_category = null, $rss_limit = null, $rss_order_by = null, $rss_order = null ) {
$parameters = array();
$rss_url_base = get_site_url() . '/smaily-rss-feed/?';
global $wp_rewrite;

$site_url = get_site_url( null, 'smaily-rss-feed' );
$parameters = array();

if ( isset( $rss_category ) && $rss_category !== '' ) {
$parameters['category'] = $rss_category;
Expand All @@ -308,12 +310,17 @@ public static function make_rss_feed_url( $rss_category = null, $rss_limit = nul
if ( isset( $rss_order_by ) && $rss_order_by !== 'none' ) {
$parameters['order_by'] = $rss_order_by;
}
// Check if providing ?order is even necessary.
if ( isset( $rss_order ) && $rss_order_by !== 'none' && $rss_order_by !== 'rand' ) {
$parameters['order'] = $rss_order;
}

return add_query_arg( $parameters, get_site_url( null, 'smaily-rss-feed' ) );
// Handle URL when permalinks have not been enabled.
if ( $wp_rewrite->using_permalinks() === false ) {
$site_url = get_site_url();
$parameters['smaily-rss-feed'] = 'true';
}

return add_query_arg( $parameters, $site_url );
}

}
29 changes: 12 additions & 17 deletions inc/Rss/SmailyRss.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@ class SmailyRss {
* @return void
*/
public function register() {
/* Rewrite Rules */
add_action( 'init', array( $this, 'smaily_rewrite_rules' ) );
/* Query Vars */
add_filter( 'query_vars', array( $this, 'smaily_register_query_var' ) );
/* Template Include */
add_filter( 'template_include', array( $this, 'smaily_rss_feed_template_include' ) );
/* Frontend settings */
add_filter( 'template_include', array( $this, 'smaily_rss_feed_template_include' ), 100 );
add_filter( 'smaily_settings', array( $this, 'smaily_rss_settings' ) );
}

Expand Down Expand Up @@ -60,20 +56,19 @@ public function smaily_register_query_var( $vars ) {
* @return string Updated template location
*/
public function smaily_rss_feed_template_include( $template ) {
global $wp_query; // Load $wp_query object.
if ( isset( $wp_query->query_vars['smaily-rss-feed'] ) ) {
// Check for query var "smaily-rss-feed".
$page_value = $wp_query->query_vars['smaily-rss-feed'];
// Verify "smaily-rss-feed" exists and value is "true".
if ( $page_value && $page_value === 'true' ) {
// Load your template or file.
return SMAILY_PLUGIN_PATH . 'templates/smaily-rss-feed.php';
}
}
// When rewrite rules database hasn't been refreshed yet.
if ( array_key_exists( 'pagename', $wp_query->query ) && $wp_query->query['pagename'] === 'smaily-rss-feed' ) {
$render_rss_feed = get_query_var( 'smaily-rss-feed', false );
$render_rss_feed = $render_rss_feed === 'true' ? '1' : $render_rss_feed;
$render_rss_feed = (bool) (int) $render_rss_feed;

$pagename = get_query_var( 'pagename' );

// Render products RSS feed, if requested.
if ( $render_rss_feed === true ) {
return SMAILY_PLUGIN_PATH . 'templates/smaily-rss-feed.php';
} elseif ( $pagename === 'smaily-rss-feed' ) {
return SMAILY_PLUGIN_PATH . 'templates/smaily-rss-feed.php';
}

// Load normal template as a fallback.
return $template;
}
Expand Down
Binary file modified lang/smaily-et.mo
Binary file not shown.
16 changes: 8 additions & 8 deletions lang/smaily-et.po
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ msgstr ""
"Project-Id-Version: Smaily for WooCommerce\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/smaily-for-"
"woocommerce\n"
"POT-Creation-Date: 2021-07-30 14:14+0300\n"
"PO-Revision-Date: 2021-07-30 14:14+0300\n"
"POT-Creation-Date: 2022-06-17 09:58+0300\n"
"PO-Revision-Date: 2022-06-17 09:58+0300\n"
"Last-Translator: \n"
"Language-Team: Estonian\n"
"Language: et\n"
Expand All @@ -14,7 +14,7 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Poedit-Basepath: ..\n"
"X-Poedit-KeywordsList: __;_e;esc_html__;esc_attr__;esc_attr_e;esc_html_e\n"
"X-Generator: Poedit 2.3\n"
"X-Generator: Poedit 3.0.1\n"
"X-Loco-Version: 2.3.3; wp-5.4.1\n"
"X-Poedit-SearchPath-0: .\n"

Expand Down Expand Up @@ -50,23 +50,23 @@ msgstr "Palun sisesta kasutajatunnus!"
msgid "Please enter password!"
msgstr "Palun sisesta salasõna!"

#: inc/Api/Api.php:142
#: inc/Api/Api.php:141
msgid "Invalid API credentials, no connection!"
msgstr "Vale kasutajatunnus või parool, ühendus puudub!"

#: inc/Api/Api.php:149
#: inc/Api/Api.php:148
msgid "Invalid subdomain, no connection!"
msgstr "Vale alamdomeen, ühendus puudub!"

#: inc/Api/Api.php:162
#: inc/Api/Api.php:161
msgid "RSS product limit value must be between 1 and 250!"
msgstr "Uudisvoo toodete arvu piirang peab olema 1 ja 250 vahel!"

#: inc/Api/Api.php:207
#: inc/Api/Api.php:206
msgid "Something went wrong saving settings!"
msgstr "Midagi läks sätete salvestamisel valesti!"

#: inc/Api/Api.php:273
#: inc/Api/Api.php:271
msgid "Check details, no connection!"
msgstr "Kontrolli sisselogimisandmeid, ühendus puudub!"

Expand Down
Binary file modified lang/smaily-et_EE.mo
Binary file not shown.
16 changes: 8 additions & 8 deletions lang/smaily-et_EE.po
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ msgstr ""
"Project-Id-Version: Smaily for WooCommerce\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/smaily-for-"
"woocommercewoocommerce\n"
"POT-Creation-Date: 2021-07-30 14:15+0300\n"
"PO-Revision-Date: 2021-07-30 14:15+0300\n"
"POT-Creation-Date: 2022-06-17 09:58+0300\n"
"PO-Revision-Date: 2022-06-17 09:58+0300\n"
"Last-Translator: \n"
"Language-Team: Estonian\n"
"Language: et\n"
Expand All @@ -14,7 +14,7 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Poedit-Basepath: ..\n"
"X-Poedit-KeywordsList: __;_e;esc_html__;esc_attr__;esc_attr_e;esc_html_e\n"
"X-Generator: Poedit 2.3\n"
"X-Generator: Poedit 3.0.1\n"
"X-Loco-Version: 2.3.3; wp-5.4.1\n"
"X-Poedit-SearchPath-0: .\n"
"X-Poedit-SearchPathExcluded-0: vendor\n"
Expand Down Expand Up @@ -51,23 +51,23 @@ msgstr "Palun sisesta kasutajatunnus!"
msgid "Please enter password!"
msgstr "Palun sisesta salasõna!"

#: inc/Api/Api.php:142
#: inc/Api/Api.php:141
msgid "Invalid API credentials, no connection!"
msgstr "Vale kasutajatunnus või parool, ühendus puudub!"

#: inc/Api/Api.php:149
#: inc/Api/Api.php:148
msgid "Invalid subdomain, no connection!"
msgstr "Vale alamdomeen, ühendus puudub!"

#: inc/Api/Api.php:162
#: inc/Api/Api.php:161
msgid "RSS product limit value must be between 1 and 250!"
msgstr "Uudisvoo toodete arvu piirang peab olema 1 ja 250 vahel!"

#: inc/Api/Api.php:207
#: inc/Api/Api.php:206
msgid "Something went wrong saving settings!"
msgstr "Midagi läks sätete salvestamisel valesti!"

#: inc/Api/Api.php:273
#: inc/Api/Api.php:271
msgid "Check details, no connection!"
msgstr "Kontrolli sisselogimisandmeid, ühendus puudub!"

Expand Down
16 changes: 8 additions & 8 deletions lang/smaily.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ msgid ""
msgstr ""
"Project-Id-Version: Smaily for WooCommerce 1.5.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/smaily-for-woocommerce\n"
"POT-Creation-Date: 2022-06-17 09:58+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2021-07-30 14:14+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: Poedit 2.3\n"
"X-Generator: Poedit 3.0.1\n"
"X-Domain: smaily\n"
"X-Poedit-Basepath: ..\n"
"X-Poedit-KeywordsList: __;_e;esc_html__;esc_attr__;esc_attr_e;esc_html_e\n"
Expand Down Expand Up @@ -51,23 +51,23 @@ msgstr ""
msgid "Please enter password!"
msgstr ""

#: inc/Api/Api.php:142
#: inc/Api/Api.php:141
msgid "Invalid API credentials, no connection!"
msgstr ""

#: inc/Api/Api.php:149
#: inc/Api/Api.php:148
msgid "Invalid subdomain, no connection!"
msgstr ""

#: inc/Api/Api.php:162
#: inc/Api/Api.php:161
msgid "RSS product limit value must be between 1 and 250!"
msgstr ""

#: inc/Api/Api.php:207
#: inc/Api/Api.php:206
msgid "Something went wrong saving settings!"
msgstr ""

#: inc/Api/Api.php:273
#: inc/Api/Api.php:271
msgid "Check details, no connection!"
msgstr ""

Expand Down
8 changes: 7 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Requires PHP: 5.6
Requires at least: 4.5
Tested up to: 5.8
WC tested up to: 4.7.0
Stable tag: 1.9.1
Stable tag: 1.9.2
License: GPLv3

Simple and flexible Smaily newsletter and RSS-feed integration for WooCommerce.
Expand Down Expand Up @@ -151,6 +151,12 @@ Also you can determine if customer had more than 10 items in cart

== Changelog ==

= 1.9.2 =

- Generating RSS feed URL takes account permalinks enabled state.
- RSS feed template is rendered at a later stage to ensure RSS is rendered.
- Use common practice on formatting User-Agent string.

= 1.9.1 =

- Update user manual links.
Expand Down
4 changes: 2 additions & 2 deletions smaily-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Plugin Name: Smaily for WooCommerce
* Plugin URI: https://github.com/sendsmaily/smaily-woocommerce-plugin
* Description: Smaily email marketing and automation extension plugin for WooCommerce. Set up easy sync for your contacts, add opt-in subscription form, import products directly to your email template and send abandoned cart reminder emails.
* Version: 1.9.1
* Version: 1.9.2
* License: GPL3
* Author: Smaily
* Author URI: https://smaily.com/
Expand Down Expand Up @@ -48,7 +48,7 @@
define( 'SMAILY_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
define( 'SMAILY_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'SMAILY_PLUGIN_NAME', plugin_basename( __FILE__ ) );
define( 'SMAILY_PLUGIN_VERSION', '1.9.1' );
define( 'SMAILY_PLUGIN_VERSION', '1.9.2' );

// Required to use functions is_plugin_active and deactivate_plugins.
require_once ABSPATH . 'wp-admin/includes/plugin.php';
Expand Down

0 comments on commit 226e666

Please sign in to comment.