first commit
This commit is contained in:
29
wp-content/plugins/flexible-checkout-fields/vendor/wpdesk/ltv-dashboard-widget/CHANGELOG.md
vendored
Normal file
29
wp-content/plugins/flexible-checkout-fields/vendor/wpdesk/ltv-dashboard-widget/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
## 1.4.0 - 2022-09-02
|
||||
### Changed
|
||||
- Copy
|
||||
|
||||
## 1.3.2 - 2022-08-01
|
||||
### Fixed
|
||||
- Connection to API
|
||||
|
||||
## 1.3.1 - 2022-07-28
|
||||
### Fixed
|
||||
- Translation of buttons
|
||||
|
||||
## 1.3.0 - 2022-07-28
|
||||
### Fixed
|
||||
- Loading of CSS styles
|
||||
|
||||
## 1.2.0 - 2022-07-22
|
||||
### Fixed
|
||||
- Empty src attribute value for image
|
||||
- No space between buttons
|
||||
### Added
|
||||
- Escaping for data output
|
||||
- Paragraph tag for plugin name
|
||||
|
||||
## 1.1.0 - 2022-07-19
|
||||
### Added
|
||||
- Mutex so metabox can be added only once
|
||||
|
||||
## 1.0.0 - 2022-07-06
|
||||
21
wp-content/plugins/flexible-checkout-fields/vendor/wpdesk/ltv-dashboard-widget/LICENSE.md
vendored
Normal file
21
wp-content/plugins/flexible-checkout-fields/vendor/wpdesk/ltv-dashboard-widget/LICENSE.md
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 WP Desk
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
42
wp-content/plugins/flexible-checkout-fields/vendor/wpdesk/ltv-dashboard-widget/composer.json
vendored
Normal file
42
wp-content/plugins/flexible-checkout-fields/vendor/wpdesk/ltv-dashboard-widget/composer.json
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "wpdesk/ltv-dashboard-widget",
|
||||
"description": "Library for displaying ltv widget in WordPress dashboard.",
|
||||
"license": "MIT",
|
||||
"keywords": ["wordpress", "notice", "admin"],
|
||||
"minimum-stability": "stable",
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "7.0"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "<7",
|
||||
"wp-coding-standards/wpcs": "^0.14.1",
|
||||
"squizlabs/php_codesniffer": "^3.0.2",
|
||||
"mockery/mockery": "*",
|
||||
"10up/wp_mock": "*",
|
||||
"wimg/php-compatibility": "^8"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {"WPDesk\\Dashboard\\": "src/"}
|
||||
},
|
||||
"extra": {
|
||||
"text-domain": "wpdesk_ltv_dashboard_widget",
|
||||
"translations-folder": "lang",
|
||||
"po-files": {
|
||||
"pl_PL": "wpdesk-ltv-dashboard-widget-pl_PL.po"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
},
|
||||
"scripts": {
|
||||
"phpcs": "phpcs",
|
||||
"phpunit-unit": "phpunit --configuration phpunit-unit.xml --coverage-text --colors=never",
|
||||
"phpunit-unit-fast": "phpunit --configuration phpunit-unit.xml --no-coverage",
|
||||
"phpunit-integration": "phpunit --configuration phpunit-integration.xml --coverage-text --colors=never",
|
||||
"phpunit-integration-fast": "phpunit --configuration phpunit-integration.xml --no-coverage"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"POT-Creation-Date: 2022-07-28 14:16+0200\n"
|
||||
"PO-Revision-Date: 2022-09-02 17:28+0200\n"
|
||||
"Last-Translator: Krzysztof Dyszczyk <krzysztof.dyszczyk@gmail.com>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: pl_PL\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
|
||||
"|| n%100>=20) ? 1 : 2);\n"
|
||||
"X-Generator: Poedit 3.1\n"
|
||||
"X-Poedit-Basepath: ../src\n"
|
||||
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
|
||||
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
|
||||
"\"\n"
|
||||
"X-Poedit-SearchPath-0: .\n"
|
||||
|
||||
#: DashboardWidget.php:19
|
||||
msgid "Expand your business with WP Desk"
|
||||
msgstr "Rozwijaj swój sklep razem z WP Desk"
|
||||
|
||||
#: DashboardWidget.php:117
|
||||
msgid "More info"
|
||||
msgstr "Więcej"
|
||||
|
||||
#: DashboardWidget.php:119
|
||||
msgid "Buy now"
|
||||
msgstr "Kup teraz"
|
||||
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
|
||||
namespace WPDesk\Dashboard;
|
||||
|
||||
final class DashboardWidget {
|
||||
const ID = 'wpdesk_ltv_dashboard_widget';
|
||||
const MUTEX_HOOK = 'wpdesk/ltvdashboard/initialized';
|
||||
|
||||
public function hooks() {
|
||||
if (apply_filters(self::MUTEX_HOOK, false) === false) {
|
||||
add_filter(self::MUTEX_HOOK, '__return_true');
|
||||
add_action( 'wp_dashboard_setup', [ $this, 'add_widget' ] );
|
||||
}
|
||||
}
|
||||
|
||||
public function add_widget() {
|
||||
wp_add_dashboard_widget(
|
||||
self::ID,
|
||||
__( 'Grow your business with WP Desk', 'wpdesk_ltv_dashboard_widget' ),
|
||||
[ $this, 'widget_output' ],
|
||||
null,
|
||||
null,
|
||||
'normal',
|
||||
'high'
|
||||
);
|
||||
}
|
||||
|
||||
private function get_all_plugins_dirs(): array {
|
||||
$all_plugins = array_keys( get_plugins() );
|
||||
|
||||
return array_map( 'dirname', $all_plugins );
|
||||
}
|
||||
|
||||
private function filter_plugins_to_show( array $plugins ): array {
|
||||
usort( $plugins, static function ( $a, $b ) {
|
||||
return strnatcmp( $a['priority'], $b['priority'] );
|
||||
} );
|
||||
$installed_plugins_dir = $this->get_all_plugins_dirs();
|
||||
$plugins = array_filter( $plugins, static function ( $plugin ) use ( $installed_plugins_dir ) {
|
||||
return ! in_array( $plugin['slug'], $installed_plugins_dir, true );
|
||||
} );
|
||||
|
||||
return array_slice( $plugins, 0, 3 );
|
||||
}
|
||||
|
||||
private function get_server(): string {
|
||||
$locale = get_user_locale();
|
||||
if ( $locale === 'pl_PL' ) {
|
||||
return 'www.wpdesk.pl';
|
||||
}
|
||||
|
||||
return 'www.wpdesk.net';
|
||||
|
||||
}
|
||||
|
||||
private function get_utm_base(): string {
|
||||
return 'utm_source=dashboard-metabox&utm_campaign=dashboard-metabox';
|
||||
}
|
||||
|
||||
private function get_widget_data(): array {
|
||||
$cache_key = sprintf( 'wpdesk_ltv_%1$s_%2$s', self::ID, get_user_locale() );
|
||||
$cache_data = get_transient( $cache_key );
|
||||
if ( $cache_data ) {
|
||||
return $cache_data;
|
||||
} elseif ( $cache_data === false ) {
|
||||
$response_data = $this->get_widget_data_from_remote();
|
||||
if ( $response_data !== null ) {
|
||||
set_transient( $cache_key, $response_data, ( 24 * 60 * 60 ) );
|
||||
return $response_data;
|
||||
} else {
|
||||
set_transient( $cache_key, null, ( 6 * 60 * 60 ) );
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
private function get_widget_data_from_remote() {
|
||||
$response = wp_remote_get(
|
||||
sprintf( 'https://%s?wpdesk_api=1&t=1', $this->get_server() ),
|
||||
[
|
||||
'timeout' => 10,
|
||||
'sslverify' => false
|
||||
]
|
||||
);
|
||||
if ( ! is_array( $response ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$ret = json_decode( $response['body'], true );
|
||||
if ( ! $ret || ! is_array( $ret ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
'header' => $ret['header'] ?? null,
|
||||
'plugins' => $this->filter_plugins_to_show( $ret['plugins'] ?? [] ),
|
||||
'footer' => $ret['footer'] ?? null,
|
||||
];
|
||||
}
|
||||
|
||||
public function widget_output() {
|
||||
$widget_data = $this->get_widget_data();
|
||||
$server = $this->get_server();
|
||||
$utm_base = $this->get_utm_base();
|
||||
|
||||
if ( ! empty( $widget_data ) ) {
|
||||
echo '<div class="wpdesk_ltv_dashboard_widget">';
|
||||
if ( $widget_data['header'] ) {
|
||||
echo wp_kses_post( $widget_data['header'] );
|
||||
}
|
||||
echo '<ul class="ltv-rows">';
|
||||
|
||||
foreach ( $widget_data['plugins'] as $plugin ) {
|
||||
$plugin_url = sprintf(
|
||||
'%1$s?%2$s&utm_medium=more-info-button&utm_term=%3$s',
|
||||
$plugin['url'],
|
||||
$utm_base,
|
||||
$plugin['slug']
|
||||
);
|
||||
$add_to_cart_url = sprintf(
|
||||
'https://%1$s/?add-to-cart=%2$s&%3$s&utm_medium=buy-now-button&utm_term=%4$s',
|
||||
$server,
|
||||
$plugin['add_to_cart_id'],
|
||||
$utm_base,
|
||||
$plugin['slug']
|
||||
);
|
||||
|
||||
echo '<li class="ltv-row">';
|
||||
if ( $plugin['image'] ) {
|
||||
echo '<img src="' . esc_url( $plugin['image'] ) . '" alt="" />';
|
||||
}
|
||||
echo '<p><strong>' . esc_html( $plugin['name'] ) . '</strong></p>';
|
||||
echo '<div class="ltv-row-description">' . wp_kses_post( $plugin['description'] ) . '</div>';
|
||||
|
||||
echo '<div class="ltv-buttons">';
|
||||
echo '<a class="button button-primary button-large" href="' . esc_url( $plugin_url ) . '" target="_blank">' . esc_html__( 'More info', 'wpdesk_ltv_dashboard_widget' ) . '</a>';
|
||||
echo ' ';
|
||||
echo '<a class="button button-large" href="' . esc_url( $add_to_cart_url ) . '" target="_blank">' . esc_html__( 'Buy now', 'wpdesk_ltv_dashboard_widget' ) . '</a>';
|
||||
echo '</div>';
|
||||
|
||||
echo '</li>';
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
|
||||
echo '<div class="ltv-footer">';
|
||||
if ( $widget_data['footer'] ) {
|
||||
echo wp_kses_post( $widget_data['footer'] );
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
?>
|
||||
<style>
|
||||
.wpdesk_ltv_dashboard_widget .ltv-rows {
|
||||
margin-left: -12px;
|
||||
margin-right: -12px;
|
||||
}
|
||||
|
||||
.wpdesk_ltv_dashboard_widget .ltv-row {
|
||||
padding: 6px 12px 24px;
|
||||
}
|
||||
|
||||
.wpdesk_ltv_dashboard_widget .ltv-row:nth-child(odd) {
|
||||
background-color: #f6f7f7;
|
||||
}
|
||||
|
||||
.wpdesk_ltv_dashboard_widget .ltv-row-description p {
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.wpdesk_ltv_dashboard_widget img {
|
||||
display: block;
|
||||
margin: 0 auto 10px;
|
||||
width: 250px;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.wpdesk_ltv_dashboard_widget .ltv-buttons {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
.wpdesk_ltv_dashboard_widget .ltv-footer {
|
||||
margin: 0 -12px;
|
||||
padding: 0 12px;
|
||||
}
|
||||
|
||||
.wpdesk_ltv_dashboard_widget .ltv-footer p {
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user