first commit

This commit is contained in:
2026-03-05 13:07:40 +01:00
commit 64ba0721ee
25709 changed files with 4691006 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
<?php
// Silence is golden.

View File

@@ -0,0 +1,2 @@
<?php
// Silence is golden.

View File

@@ -0,0 +1,136 @@
jQuery(
function() {
iworks_options_tabulator_init();
/**
* Switch button
*/
if (jQuery.fn.switchButton) {
jQuery('.iworks_options .switch-button, .iworks-options-switch-button').each(
function() {
var options = {
checked: jQuery(this).checked,
on_label: jQuery(this).data('on_label') || switch_button.labels.on_label,
off_label: jQuery(this).data('off_label') || switch_button.labels.off_label
};
jQuery(this).switchButton(options);
}
);
}
/**
* Color picker
*/
if (jQuery.fn.wpColorPicker) {
jQuery('.wpColorPicker').wpColorPicker();
}
/**
* select2
*/
if (jQuery.fn.select2) {
jQuery('.iworks-options .select2').select2();
}
/**
* slider
*/
if (jQuery.fn.slider) {
jQuery('.iworks-options .slider').each(
function() {
jQuery(this).parent().append('<div class="ui-slider"></div>');
var target = jQuery(this);
var options = {
value: parseInt(target.val()),
step: parseInt(target.data('step') || target.attr('step') || 1),
min: parseInt(target.data('min') || target.attr('min') || 0),
max: parseInt(target.data('max') || target.attr('max') || 100),
slide: function(event, ui) {
target.val(ui.value);
}
};
jQuery('.ui-slider', jQuery(this).parent()).slider(options);
}
);
}
}
);
/**
* Media
*/
jQuery(document).ready(function($) {
var iworks_options_media = [];
$('input.iworks_delete_button').on('click', function(e) {
var $parent = $(this).closest('td');
e.preventDefault();
$('img', $parent).attr('src', '');
$('input[type=hidden]', $parent).val(0);
$(this).hide();
});
$('input.iworks_upload_button').on('click', function(e) {
var $parent = $(this).closest('td');
var key = $(this).attr('rel');
e.preventDefault();
// Extend the wp.media object
if (iworks_options_media[key]) {
iworks_options_media[key].open();
return;
}
iworks_options_media[key] = wp.media.frames.file_frame = wp.media({
title: window.iworks_options.buttons.select_media,
button: {
text: window.iworks_options.buttons.select_media,
rel: this,
},
multiple: false
});
// When a file is selected, grab the URL and set it as the text field's value
iworks_options_media[key].on('select', function() {
var attachment = iworks_options_media[key].state().get('selection').first().toJSON();
$('img', $parent).attr('src', attachment.url);
$('input[type=hidden]', $parent).val(attachment.id);
$('input.iworks_delete_button', $parent).show();
});
// Open the upload dialog
iworks_options_media[key].open();
});
});
/**
* Tabulator Bootup
*/
function iworks_options_tabulator_init() {
if (!jQuery("#hasadmintabs").length) {
return;
}
jQuery('#hasadmintabs').prepend("<ul><\/ul>");
jQuery('#hasadmintabs > fieldset').each(
function(i) {
id = jQuery(this).attr('id');
rel = jQuery(this).attr('rel');
caption = jQuery(this).find('h3').text();
if (rel) {
rel = ' class="' + rel + '"';
} else {
rel = '';
}
jQuery('#hasadmintabs > ul').append('<li><a href="#' + id + '"><span' + rel + '>' + caption + "<\/span><\/a><\/li>");
jQuery(this).find('h3').hide();
}
);
index = 0;
jQuery('#hasadmintabs h3').each(
function(i) {
if (jQuery(this).hasClass('selected')) {
index = i;
}
}
);
if (index < 0) {
index = 0;
}
jQuery("#hasadmintabs").tabs({
active: index
});
jQuery('#hasadmintabs ul a').click(
function(i) {
jQuery('#hasadmintabs #last_used_tab').val(jQuery(this).parent().index());
}
);
}

View File

@@ -0,0 +1,2 @@
<?php
// Silence is golden.

View File

@@ -0,0 +1,312 @@
/**
* jquery.switchButton.js v1.0
* jQuery iPhone-like switch button
* @author Olivier Lance <olivier.lance@sylights.com>
*
* Copyright (c) Olivier Lance - released under MIT License {{{
*
* 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.
* }}}
*/
/*
* Meant to be used on a <input type="checkbox">, this widget will replace the receiver element with an iPhone-style
* switch button with two states: "on" and "off".
* Labels of the states are customizable, as are their presence and position. The receiver element's "checked" attribute
* is updated according to the state of the switch, so that it can be used in a <form>.
*
*/
(function($) {
$.widget(
"sylightsUI.switchButton",
{
options: {
checked: undefined, // State of the switch
show_labels: true, // Should we show the on and off labels?
labels_placement: "both", // Position of the labels: "both", "left" or "right"
on_label: "ON", // Text to be displayed when checked
off_label: "OFF", // Text to be displayed when unchecked
width: 25, // Width of the button in pixels
height: 11, // Height of the button in pixels
button_width: 12, // Width of the sliding part in pixels
clear: true, // Should we insert a div with style="clear: both;" after the switch button?
clear_after: null, // Override the element after which the clearing div should be inserted (null > right after the button)
on_callback: undefined, //callback function that will be executed after going to on state
off_callback: undefined //callback function that will be executed after going to off state
},
_create: function() {
// Init the switch from the checkbox if no state was specified on creation
if (this.options.checked === undefined) {
this.options.checked = this.element.prop( "checked" );
}
this._initLayout();
this._initEvents();
},
_initLayout: function() {
// Hide the receiver element
this.element.hide();
// Create our objects: two labels and the button
this.off_label = $( "<span>" ).addClass( "switch-button-label" );
this.on_label = $( "<span>" ).addClass( "switch-button-label" );
this.button_bg = $( "<div>" ).addClass( "switch-button-background" );
this.button = $( "<div>" ).addClass( "switch-button-button" );
// Insert the objects into the DOM
this.off_label.insertAfter( this.element );
this.button_bg.insertAfter( this.off_label );
this.on_label.insertAfter( this.button_bg );
this.button_bg.append( this.button );
// Insert a clearing element after the specified element if needed
if (this.options.clear) {
if (this.options.clear_after === null) {
this.options.clear_after = this.on_label;
}
$( "<div>" ).css(
{
clear: "left"
}
).insertAfter( this.options.clear_after );
}
// Call refresh to update labels text and visibility
this._refresh();
// Init labels and switch state
// This will animate all checked switches to the ON position when
// loading... this is intentional!
this.options.checked = ! this.options.checked;
this._toggleSwitch( true );
},
_refresh: function() {
// Refresh labels display
if (this.options.show_labels) {
this.off_label.show();
this.on_label.show();
} else {
this.off_label.hide();
this.on_label.hide();
}
// Move labels around depending on labels_placement option
switch (this.options.labels_placement) {
case "both":
{
// Don't move anything if labels are already in place
if (this.button_bg.prev() !== this.off_label || this.button_bg.next() !== this.on_label) {
// Detach labels form DOM and place them correctly
this.off_label.detach();
this.on_label.detach();
this.off_label.insertBefore( this.button_bg );
this.on_label.insertAfter( this.button_bg );
// Update label classes
this.on_label.addClass( this.options.checked ? "on" : "off" ).removeClass( this.options.checked ? "off" : "on" );
this.off_label.addClass( this.options.checked ? "off" : "on" ).removeClass( this.options.checked ? "on" : "off" );
}
break;
}
case "left":
{
// Don't move anything if labels are already in place
if (this.button_bg.prev() !== this.on_label || this.on_label.prev() !== this.off_label) {
// Detach labels form DOM and place them correctly
this.off_label.detach();
this.on_label.detach();
this.off_label.insertBefore( this.button_bg );
this.on_label.insertBefore( this.button_bg );
// update label classes
this.on_label.addClass( "on" ).removeClass( "off" );
this.off_label.addClass( "off" ).removeClass( "on" );
}
break;
}
case "right":
{
// Don't move anything if labels are already in place
if (this.button_bg.next() !== this.off_label || this.off_label.next() !== this.on_label) {
// Detach labels form DOM and place them correctly
this.off_label.detach();
this.on_label.detach();
this.off_label.insertAfter( this.button_bg );
this.on_label.insertAfter( this.off_label );
// update label classes
this.on_label.addClass( "on" ).removeClass( "off" );
this.off_label.addClass( "off" ).removeClass( "on" );
}
break;
}
}
// Refresh labels texts
this.on_label.html( this.options.on_label );
this.off_label.html( this.options.off_label );
// Refresh button's dimensions
this.button_bg.width( this.options.width );
this.button_bg.height( this.options.height );
this.button.width( this.options.button_width );
this.button.height( this.options.height );
},
_initEvents: function() {
var self = this;
// Toggle switch when the switch is clicked
this.button_bg.click(
function(e) {
e.preventDefault();
e.stopPropagation();
self._toggleSwitch( false );
return false;
}
);
this.button.click(
function(e) {
e.preventDefault();
e.stopPropagation();
self._toggleSwitch( false );
return false;
}
);
// Set switch value when clicking labels
this.on_label.click(
function(e) {
if (self.options.checked && self.options.labels_placement === "both") {
return false;
}
self._toggleSwitch( false );
return false;
}
);
this.off_label.click(
function(e) {
if ( ! self.options.checked && self.options.labels_placement === "both") {
return false;
}
self._toggleSwitch( false );
return false;
}
);
},
_setOption: function(key, value) {
if (key === "checked") {
this._setChecked( value );
return;
}
this.options[key] = value;
this._refresh();
},
_setChecked: function(value) {
if (value === this.options.checked) {
return;
}
this.options.checked = ! value;
this._toggleSwitch( false );
},
_toggleSwitch: function(isInitializing) {
// Don't toggle the switch if it is set to readonly or disabled, unless it is initializing and animating itself
if ( ! isInitializing && (this.element.attr( 'readonly' ) == 'readonly' || this.element.prop( 'disabled' )) ) {
return;
}
this.options.checked = ! this.options.checked;
var newLeft = "";
if (this.options.checked) {
// Update the underlying checkbox state
this.element.prop( "checked", true );
this.element.change();
var dLeft = this.options.width - this.options.button_width;
newLeft = "+=" + dLeft;
// Update labels states
if (this.options.labels_placement == "both") {
this.off_label.removeClass( "on" ).addClass( "off" );
this.on_label.removeClass( "off" ).addClass( "on" );
} else {
this.off_label.hide();
this.on_label.show();
}
this.button_bg.addClass( "checked" );
//execute on state callback if its supplied
if (typeof this.options.on_callback === 'function') {
this.options.on_callback.call( this );
}
} else {
// Update the underlying checkbox state
this.element.prop( "checked", false );
this.element.change();
newLeft = "-1px";
// Update labels states
if (this.options.labels_placement == "both") {
this.off_label.removeClass( "off" ).addClass( "on" );
this.on_label.removeClass( "on" ).addClass( "off" );
} else {
this.off_label.show();
this.on_label.hide();
}
this.button_bg.removeClass( "checked" );
//execute off state callback if its supplied
if (typeof this.options.off_callback === 'function') {
this.options.off_callback.call( this );
}
}
// Animate the switch
this.button.animate( { left: newLeft }, 250, "easeInOutCubic" );
}
}
);
})( jQuery );

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
<?php
// Silence is golden.

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@@ -0,0 +1,2 @@
<?php
// Silence is golden.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,44 @@
.switch-button-label {
float: left;
font-size: 10pt;
cursor: pointer;
}
.switch-button-label.off {
color: #adadad;
}
.switch-button-label.on {
color: #0088CC;
}
.switch-button-background {
float: left;
position: relative;
background: #ccc;
border: 1px solid #aaa;
margin: 1px 10px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
cursor: pointer;
}
.switch-button-button {
position: absolute;
left: -1px;
top : -1px;
background: #FAFAFA;
border: 1px solid #aaa;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}

View File

@@ -0,0 +1,49 @@
.iworks-options #hasadmintabs,
.iworks-options #hasadmintabs .ui-widget-header {
border: 0;
background: transparent none;
}
.iworks-options #hasadmintabs .ui-widget-header {
border-bottom: 1px solid #c5c5c5;
}
.iworks-options #hasadmintabs .form-table td {
padding: 10px;
}
@media screen and ( max-width: 425px ) {
.iworks-options #hasadmintabs .ui-widget-header a,
.iworks-options #hasadmintabs .ui-widget-header li {
display: block;
float: none;
}
}
.iworks-options-row .select2-container {
width: 100%;
min-width: 300px;
}
.iworks-options-row .ui-slider {
margin-top: 10px;
max-width: 150px;
}
@media screen and ( max-width: 768px ) {
.iworks_options .has-right-sidebar {
display: grid;
grid-template-areas: "iworks-options" "iworks-sidebar";
}
.iworks_options #side-info-column {
grid-area: iworks-sidebar;
width: 100%;
}
.iworks_options #post-body {
grid-area: iworks-options;
float: none;
}
.iworks_options .has-right-sidebar #side-sortables,
.iworks_options .has-right-sidebar #post-body-content {
width: 100%;
min-height: 0;
}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
<?php
// Silence is golden.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,107 @@
.iworks-rate {
font-family: "Exo 2", sans-serif;
padding: 20px 30px; }
.iworks-rate h4 {
margin: 10px 0 0;
padding: 4px 38px 4px 0;
font-size: 16px;
font-weight: 500;
line-height: 1.618;
--logo: attr(data-logo); }
.iworks-rate h4 strong {
font-weight: 900; }
.iworks-rate p {
font-size: 14px;
max-width: 800px;
line-height: 1.618;
margin: 0 0 10px;
padding: 4px 0; }
.iworks-rate.has-logo h4 {
display: flex;
align-items: center; }
.iworks-rate-logo {
display: block;
width: 3em;
height: 3em;
margin-right: .3em;
content: "";
background-color: transparent;
background-repeat: no-repeat;
background-position: 50%;
background-size: contain; }
.iworks-rate-buttons {
margin-top: -10px;
padding: 10px 2px;
overflow: hidden; }
.iworks-rate-buttons .iworks-rate-button {
float: left;
margin: 20px 20px 0 0; }
.iworks-rate-button {
margin: 20px auto;
position: relative;
display: inline-block;
min-width: 180px;
padding: 9px 30px;
font-weight: 500;
font-size: 14px;
line-height: 1.618;
text-align: center;
text-decoration: none;
background-color: #fff;
opacity: 1;
box-sizing: border-box;
box-shadow: none;
outline: none;
border: 1px solid transparent;
transition: color 0.3s !important;
z-index: 10;
cursor: pointer; }
.iworks-rate-button--green {
border-color: #46b450;
color: #46b450; }
.iworks-rate-button--green:after {
background-color: #46b450; }
.iworks-rate-button--green:focus {
color: #46b450;
box-shadow: 0 0 0 1px #46b450, 0 0 2px 1px rgba(79, 148, 212, 0.8);
outline: 1px solid transparent; }
.iworks-rate-button--green:hover {
color: #fff;
background-color: #46b450; }
.iworks-rate-button--blue {
border-color: #0073aa;
color: #0073aa; }
.iworks-rate-button--blue:after {
background-color: #0073aa; }
.iworks-rate-button--blue:focus {
box-shadow: 0 0 0 1px #0073aa, 0 0 2px 1px rgba(79, 148, 212, 0.8);
color: #0073aa;
outline: 1px solid transparent; }
.iworks-rate-button--blue:hover {
color: #fff;
background-color: #0073aa; }
.iworks-rate-button:before {
float: left;
margin-right: 10px;
font-family: dashicons;
font-size: 20px;
line-height: 1.1; }
.iworks-rate-button:after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 0;
bottom: 0;
transition: all ease .3s;
z-index: -1; }
.iworks-rate-button:hover:after {
width: 100%; }
.iworks-rate-center {
text-align: center; }
/*# sourceMappingURL=admin.css.map */

View File

@@ -0,0 +1,23 @@
jQuery(
function() {
var $parent = jQuery('.notice-iworks-rate');
jQuery('.iworks-rate-button, .notice-dismiss', $parent).on('click', function(e) {
var data = {
action: 'iworks_rate_button',
plugin_id: $parent.data('id'),
button: jQuery(this).data('action')
};
if ('get-help' === jQuery(this).data('action')) {
return true;
}
jQuery.post(
$parent.data('ajax-url'),
data,
function(response) {
$parent.detach();
}
);
return true;
});
}
);

View File

@@ -0,0 +1,146 @@
$au: 1.618;
$color_blue: #0073aa;
$color_green: #46b450;
$color_white: #fff;
.iworks-rate {
font-family: "Exo 2", sans-serif;
padding: 20px 30px;
h4 {
margin: 10px 0 0;
padding: 4px 38px 4px 0;
font: {
size: 16px;
weight: 500;
}
strong {
font-weight: 900;
}
line-height: $au;
--logo: attr(data-logo);
}
p {
font-size: 14px;
max-width: 800px;
line-height: $au;
margin: 0 0 10px;
padding: 4px 0;
}
&.has-logo {
h4 {
display: flex;
align-items: center;
}
}
}
.iworks-rate-logo {
display: block;
width: 3em;
height: 3em;
margin-right: .3em;
content: "";
background: {
color: transparent;
repeat: no-repeat;
position: 50%;
size: contain;
}
}
.iworks-rate-buttons {
margin-top: -10px;
padding: 10px 2px;
overflow: hidden;
.iworks-rate-button {
float: left;
margin: 20px 20px 0 0;
}
}
.iworks-rate-button {
margin: 20px auto;
position: relative;
display: inline-block;
min-width: 180px;
padding: 9px 30px;
font: {
weight: 500;
size: 14px;
}
line-height: $au;
text: {
align: center;
decoration: none;
}
background-color: $color_white;
opacity: 1;
box-sizing: border-box;
box-shadow: none;
outline: none;
border: 1px solid transparent;
transition: color .3s!important;
z-index: 10;
cursor: pointer;
&--green {
border-color: $color_green;
color: $color_green;
&:after {
background-color: $color_green;
}
&:focus {
color: $color_green;
box-shadow: 0 0 0 1px $color_green,0 0 2px 1px rgba(79,148,212,.8);
outline: 1px solid transparent
}
&:hover {
color: $color_white;
background-color: $color_green;
}
}
&--blue {
border-color: $color_blue;
color: $color_blue;
&:after {
background-color: $color_blue;
}
&:focus {
box-shadow: 0 0 0 1px $color_blue,0 0 2px 1px rgba(79,148,212,.8);
color: $color_blue;
outline: 1px solid transparent
}
&:hover {
color: $color_white;
background-color: $color_blue;
}
}
&:before{
float: left;
margin-right: 10px;
font-family: dashicons;
font-size: 20px;
line-height: 1.1;
}
&:after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 0;
bottom: 0;
transition: all ease .3s;
z-index: -1;
}
&:hover {
&:after {
width: 100%;
}
}
}
.iworks-rate-center {
text-align: center;
}

View File

@@ -0,0 +1 @@
<svg width="500" height="500" xmlns="http://www.w3.org/2000/svg"><path fill="#231f20" d="m 216.7,383.1 c -91.8,0 -166.4,-74.5 -166.4,-166.4 0,-32.4 9.5,-62.4 25.5,-88.0 -2.6,7.9 -4.0,16.4 -4.0,25.3 0,45.5 36.8,82.4 82.3,82.4 45.4,0 82.3,-36.9 82.3,-82.4 0,-45.4 -36.9,-82.3 -82.3,-82.3 -8.8,0 -17.3,1.4 -25.2,4.0 25.5,-16 55.5,-25.3 87.7,-25 91.8,0 166.4,74.5 166.4,166.4 0,91.9 -74.6,166.4 -166.4,166.4 M 75.5,357.9 28.5,404.9 c 48.2,48.1 114.7,78 188.2,78 147,0 266.2,-119.2 266.2,-266.2 0,-73.5 -29.8,-140.1 -78,-188.2 l -47.1,47.0 0.1,0.1 c -36.2,-36.2 -86.1,-58.5 -141.2,-58.5 -110.2,0 -199.6,89.4 -199.6,199.6 0,55.0 22.3,104.9 58.4,141 v 0.2 z" /></svg>

After

Width:  |  Height:  |  Size: 661 B

View File

@@ -0,0 +1,534 @@
<?php
defined( 'ABSPATH' ) || exit; // Exit if accessed directly
/**
* iWorks_Rate - Dashboard Notification module.
*
* @version 2.1.3
* @author iworks (Marcin Pietrzak)
*
*/
if ( ! class_exists( 'iworks_rate' ) ) {
class iworks_rate {
/**
* This class version.
*
* @since 1.0.1
* @var string
*/
private $version = '2.1.3';
/**
* $wpdb->options field name.
*
* @since 1.0.0
* @var string
*/
protected $option_name = 'iworks_rates';
/**
* List of all registered plugins.
*
* @since 1.0.0
* @var array
*/
protected $plugins = array();
/**
* Module options that are stored in database.
* Timestamps are stored here.
*
* Note that this option is stored in site-meta for multisite installs.
*
* @since 1.0.0
* @var array
*/
protected $stored = array();
/**
* Initializes and returns the singleton instance.
*
* @since 1.0.0
*/
static public function instance() {
static $Inst = null;
if ( null === $Inst ) {
$Inst = new iworks_rate();
}
return $Inst;
}
/**
* Set up the iworks_rate module. Private singleton constructor.
*
* @since 1.0.0
*/
private function __construct() {
/**
* settings
*/
$this->stored = wp_parse_args(
get_site_option( $this->option_name, false, false ),
array()
);
/**
* actions
*/
add_action( 'load-index.php', array( $this, 'load' ) );
add_action( 'iworks-register-plugin', array( $this, 'register' ), 5, 3 );
add_action( 'wp_ajax_iworks_rate_button', array( $this, 'ajax_button' ) );
add_action( 'admin_init', array( $this, 'admin_init' ) );
/**
* own hooks
*/
add_filter( 'iworks_rate_assistance', array( $this, 'filter_get_assistance_widget' ), 10, 2 );
add_filter( 'iworks_rate_love', array( $this, 'filter_get_love_widget' ), 10, 2 );
/**
* advertising
*
* @since 2.1.0
*/
add_filter( 'iworks_rate_advertising_og', array( $this, 'filter_get_advertising_og' ) );
}
/**
* Inicialize admin area
*
* @since 2.0.2
*/
public function admin_init() {
foreach ( $this->plugins as $plugin_file => $plugin ) {
add_filter( 'plugin_action_links_' . $plugin_file, array( $this, 'add_donate_link' ), 10, 4 );
}
}
/**
* Add donate link to plugin_row_meta.
*
* @since 2.0.2
*
* @param array $actions An array of the plugin's metadata, including the version, author, author URI, and plugin URI.
*/
public function add_donate_link( $actions, $plugin_file, $plugin_data, $context ) {
$slug = 'iworks';
if (
isset( $this->plugins[ $plugin_file ] )
&& isset( $this->plugins[ $plugin_file ]['slug'] )
) {
$slug = $this->plugins[ $plugin_file ]['slug'];
}
$settings_page_url = apply_filters( 'iworks_rate_settings_page_url_' . $slug, null );
if ( ! empty( $settings_page_url ) ) {
$actions['settings'] = sprintf(
'<a href="%s">%s</a>',
esc_url( $settings_page_url ),
esc_html__( 'Settings', 'sierotki' )
);
}
$actions['donate'] = sprintf(
'<a href="%s" target="_blank">%s</a>',
esc_url(
add_query_arg(
array(
'utm_source' => $slug,
'utm_medium' => 'plugin-links',
),
'https://ko-fi.com/iworks'
)
),
esc_html__( 'Provide us a coffee', 'sierotki' )
);
return $actions;
}
public function load() {
$plugin_id = $this->choose_plugin();
if ( empty( $plugin_id ) ) {
return;
}
$this->plugin_id = $plugin_id;
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
add_action( 'admin_notices', array( $this, 'show' ) );
}
/**
* Save persistent module-data to the WP database.
*
* @since 1.0.0
*/
protected function store_data() {
update_site_option( $this->option_name, $this->stored );
}
/**
* Action handler for 'iworks-register-plugin'
* Register an active plugin.
*
* @since 1.0.0
* @param string $plugin_id WordPress plugin-ID (see: plugin_basename).
* @param string $title Plugin name for display.
* @param string $slug the plugin slug on wp.org
*/
public function register( $plugin_id, $title, $slug ) {
// Ignore incorrectly registered plugins to avoid errors later.
if ( empty( $plugin_id ) || empty( $title ) || empty( $slug ) ) {
return;
}
$data = array(
'title' => $title,
'slug' => $slug,
);
$this->plugins[ $plugin_id ] = $data;
/**
* check for option update
*
* @since 2.0.6
*
*/
$update = false;
/*
* When the plugin is registered the first time we store some infos
* in the persistent module-data that help us later to find out
* if/which message should be displayed.
*/
if ( empty( $this->stored[ $plugin_id ] ) ) {
$this->stored[ $plugin_id ] = wp_parse_args(
array(
'registered' => time(),
'show_at' => time() + rand( 7, 14 ) * DAY_IN_SECONDS,
'rated' => 0,
'hide' => 0,
),
$data
);
$update = true;
}
/**
* check slug & mark for update if needed
*
* @since 2.0.6
*/
if ( $this->stored[ $plugin_id ]['slug'] !== $slug ) {
$this->stored[ $plugin_id ]['slug'] = $slug;
$update = true;
}
/**
* check title - can be diferent due language
*
* @since 2.0.6
*/
$this->stored[ $plugin_id ]['title'] = $title;
/**
* Finally save the details if it is needed
*/
if ( $update ) {
$this->store_data();
}
}
/**
* Ajax handler called when the user chooses the CTA button.
*
* @since 1.0.0
*/
public function ajax_button() {
$plugin_id = filter_input( INPUT_POST, 'plugin_id', FILTER_DEFAULT );
if ( empty( $plugin_id ) ) {
wp_send_json_error();
}
/**
* sanitize plugin_id
*
* @since 2.1.3
*/
$plugin_id = sanitize_text_field( $plugin_id );
if ( ! isset( $this->plugins[ $plugin_id ] ) ) {
wp_send_json_error();
}
/**
* sanitize button value
*
* @since 2.1.3
*/
$value = '';
if ( isset( $_POST['button'] ) ) {
$value = sanitize_text_field( filter_input( INPUT_POST, 'button', FILTER_DEFAULT ) );
}
switch ( $value ) {
case '':
case 'add-review':
$this->add_weeks( $plugin_id );
wp_send_json_success();
case 'hide':
$this->add_weeks( $plugin_id );
$this->hide( $plugin_id );
wp_send_json_success();
case 'donate':
$this->add_months( $plugin_id );
wp_send_json_success();
}
wp_send_json_success();
}
public function hide( $plugin_id ) {
if ( ! isset( $this->stored[ $plugin_id ] ) ) {
return;
}
$this->stored[ $plugin_id ]['rated'] = time();
$this->store_data();
}
private function add_weeks( $plugin_id ) {
if ( ! isset( $this->stored[ $plugin_id ] ) ) {
return;
}
$this->stored[ $plugin_id ]['show_at'] = time() + rand( 4, 6 ) * WEEK_IN_SECONDS + rand( 0, 7 ) * DAY_IN_SECONDS;
$this->store_data();
}
private function add_months( $plugin_id ) {
if ( ! isset( $this->stored[ $plugin_id ] ) ) {
return;
}
$this->stored[ $plugin_id ]['show_at'] = time() + rand( 15, 30 ) * WEEK_IN_SECONDS + rand( 0, 14 ) * DAY_IN_SECONDS;
$this->store_data();
}
/**
* Ajax handler called when the user chooses the dismiss button.
*
* @since 1.0.0
*/
public function dismiss() {
$plugin = $this->get_plugin_from_post();
if ( is_wp_error( $plugin ) ) {
wp_send_json_error();
}
wp_send_json_success();
}
/**
* Action handler for 'load-index.php'
* Set-up the Dashboard notification.
*
* @since 1.0.0
*/
public function enqueue() {
wp_enqueue_style(
__CLASS__,
plugin_dir_url( __FILE__ ) . 'admin.css',
array(),
$this->version
);
wp_enqueue_script(
__CLASS__,
plugin_dir_url( __FILE__ ) . 'admin.js',
array(),
$this->version,
true
);
}
/**
* Action handler for 'admin_notices'
* Display the Dashboard notification.
*
* @since 1.0.0
*/
public function show() {
$this->render_message( $this->plugin_id );
}
/**
* Check to see if there is a pending message to display and returns
* the message details if there is.
*
* Note that this function is only called on the main Dashboard screen
* and only when logged in as super-admin.
*
* @since 1.0.0
* @return object|false
* string $plugin WordPress plugin ID?
*/
protected function choose_plugin() {
if ( wp_is_mobile() ) {
return false;
}
/**
* list
*/
$choosen = array();
/**
* change time by filter
*/
$now = apply_filters( 'iworks_rate_set_custom_time', time() );
foreach ( $this->stored as $plugin_id => $item ) {
if ( ! isset( $this->plugins[ $plugin_id ] ) ) {
if ( isset( $this->stored[ $plugin_id ] ) ) {
unset( $this->stored[ $plugin_id ] );
$this->store_data();
}
continue;
}
if ( intval( $item['show_at'] ) > $now ) {
continue;
}
$choosen[] = $plugin_id;
}
if ( empty( $choosen ) ) {
return false;
}
return $choosen[ array_rand( $choosen ) ];
}
/**
* Renders the actual Notification message.
*
* @since 1.0.0
*/
protected function render_message( $plugin_id ) {
$file = $this->get_file( 'thanks' );
$plugin = $this->get_plugin_data_by_plugin_id( $plugin_id );
load_template( $file, true, $plugin );
}
/**
* @since 2.0.1
*/
private function get_file( $file, $group = '' ) {
return sprintf(
'%s/templates/%s%s%s.php',
dirname( __FILE__ ),
$group,
'' === $group ? '' : '/',
sanitize_title( $file )
);
}
/**
* @since 2.0.1
*/
private function get_plugin_data_by_plugin_id( $plugin_id ) {
$plugin = wp_parse_args(
$this->plugins[ $plugin_id ],
$this->stored[ $plugin_id ]
);
$plugin['plugin_id'] = $plugin_id;
$plugin['logo'] = apply_filters( 'iworks_rate_notice_logo_style', '', $plugin );
$plugin['ajax_url'] = admin_url( 'admin-ajax.php' );
$plugin['classes'] = array(
'iworks-rate',
'iworks-rate-' . $plugin['slug'],
'iworks-rate-notice',
);
if ( ! empty( $plugin['logo'] ) ) {
$plugin['classes'][] = 'has-logo';
}
$plugin['url'] = esc_url(
sprintf(
_x( 'https://wordpress.org/plugins/%s', 'plugins home', 'sierotki' ),
$plugin['slug']
)
);
$plugin['support_url'] = esc_url(
sprintf(
_x( 'https://wordpress.org/support/plugin/%s', 'plugins support home', 'sierotki' ),
$plugin['slug']
)
);
return $plugin;
}
/**
* @since 2.0.1
*/
private function get_plugin_id_by_slug( $slug ) {
foreach ( $this->stored as $plugin_id => $plugin ) {
if ( $slug === $plugin['slug'] ) {
return $plugin_id;
}
}
return new WP_Error();
}
/**
* @since 2.0.1
*/
public function filter_get_assistance_widget( $content, $slug ) {
$plugin_id = $this->get_plugin_id_by_slug( $slug );
if ( is_wp_error( $plugin_id ) ) {
return $content;
}
$this->enqueue();
$plugin = $this->get_plugin_data_by_plugin_id( $plugin_id );
$file = $this->get_file( 'support', 'widgets' );
ob_start();
load_template( $file, true, $plugin );
$content = ob_get_contents();
ob_end_clean();
return $content;
}
/**
* @since 2.0.1
*/
public function filter_get_love_widget( $content, $slug ) {
$plugin_id = $this->get_plugin_id_by_slug( $slug );
if ( is_wp_error( $plugin_id ) ) {
return $content;
}
$this->enqueue();
$plugin = $this->get_plugin_data_by_plugin_id( $plugin_id );
$file = $this->get_file( 'donate', 'widgets' );
ob_start();
load_template( $file, true, $plugin );
$content = ob_get_contents();
ob_end_clean();
return $content;
}
/**
* Get advertising for "OG — Better Share on Social Media" plugin.
*
* @since 2.1.0
*/
public function filter_get_advertising_og( $data ) {
return array(
'iworks-adverting-og' => array(
'title' => __( 'OpenGraph', 'sierotki' ),
'callback' => array( $this, 'get_advertising_og_content' ),
'context' => 'side',
'priority' => 'low',
),
);
}
/**
* Advertising content for "OG — Better Share on Social Media" plugin.
*
* @since 2.1.0
*/
public function get_advertising_og_content() {
$args = array(
'install_plugin_url' => $this->get_install_plugin_url( 'og' ),
'plugin_name' => __( 'OG — Better Share on Social Media', 'sierotki' ),
'plugin_wp_home' => __( 'https://wordpress.org/plugins/og/', 'sierotki' ),
);
$file = $this->get_file( 'og', 'plugins' );
load_template( $file, true, $args );
}
/**
* get admin plugin install url
*
* @since 2.1.0
*/
private function get_install_plugin_url( $slug ) {
return wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $slug ), 'install-plugin_' . $slug );
}
}
// Initialize the module.
iworks_rate::instance();
}

View File

@@ -0,0 +1,23 @@
<?php
defined( 'ABSPATH' ) || exit; // Exit if accessed directly
?>
<p>
<?php
esc_html_e( 'Would you like to boost your website sharing abilities?', 'sierotki ' );
?>
</p>
<p>
<?php
printf(
esc_html__( 'Don\'t wait, install plugin %s!', 'sierotki' ),
sprintf(
'<a href="%s" target="_blank"><strong>%s</strong></a>',
$args['plugin_wp_home'],
$args['plugin_name']
)
);
?>
</p>
<p class="iworks-rate-center"><a href="<?php echo esc_url( $args['install_plugin_url'] ); ?>" class="iworks-rate-button iworks-rate-button--green dashicons-admin-plugins
"><?php echo esc_html( __( 'Install', 'sierotki' ) ); ?></a></p>

View File

@@ -0,0 +1,35 @@
<?php
defined( 'ABSPATH' ) || exit; // Exit if accessed directly
/**
* Notice displayed in admin panel.
*/
?>
<div class="notice notice-success is-dismissible notice-iworks-rate"
data-slug="<?php echo esc_attr( $args['slug'] ); ?>"
data-id="<?php echo esc_attr( $args['plugin_id'] ); ?>"
data-ajax-url="<?php echo esc_url( $args['ajax_url'] ); ?>"
>
<div class="<?php echo esc_attr( implode( ' ', $args['classes'] ) ); ?>">
<h4>
<?php
if ( ! empty( $args['logo'] ) ) {
printf( '<span class="iworks-rate-logo" style="background-image:url(%s)"></span>', esc_url( $args['logo'] ) ); }
?>
<span><?php printf( esc_html( __( 'Thank you for using our plugin %s!', 'sierotki' ) ), sprintf( '<strong>%s</strong>', $args['title'] ) ); ?></span></h4>
<?php
/* translators: %1$s: open anchor tag, %2$s: close anchor tag */
$content = __( 'Please let us know what you think about our plugin. It is important that we can develop this tool. Thank you for all the ratings, reviews and donates. If you have a technical problem, please before you add a review %1$scheck our FAQ%2$s or contact us if you did not find help there. We will try to help you!', 'sierotki' );
echo wpautop( wp_kses_post( sprintf( $content, sprintf( '<a href="%s#faq" target="_blank">', $args['url'] ), '</a>' ) ) );
?>
<div class="iworks-rate-buttons">
<a data-action="get-help" href="<?php echo $args['support_url']; ?>/#new-post" target="_blank" class="iworks-rate-button iworks-rate-button--green" ><?php echo esc_html( __( 'Get help', 'sierotki' ) ); ?></a>
<?php if ( intval( $args['rated'] ) === 0 ) { ?>
<a data-action="add-review" href="<?php echo $args['support_url']; ?>/reviews/?rate=5#new-post" target="_blank" class="iworks-rate-button iworks-rate-button--green" ><?php echo esc_html( __( 'Add review', 'sierotki' ) ); ?></a>
<?php } ?>
<a data-action="donate" href="https://ko-fi.com/iworks/?utm_source=<?php echo $args['slug']; ?>&utm_medium=notice-thanks" target="_blank" class="iworks-rate-button iworks-rate-button--green dashicons-heart" ><?php echo esc_html( __( 'Provide us a coffee', 'sierotki' ) ); ?></a>
<?php if ( intval( $args['rated'] ) === 0 ) { ?>
<button type="button" data-action="hide" class="iworks-rate-button iworks-rate-button--blue" ><?php echo esc_html( __( 'I added review, do not show again', 'sierotki' ) ); ?></button>
<?php } ?>
</div>
</div>
</div>

View File

@@ -0,0 +1,5 @@
<?php defined( 'ABSPATH' ) || exit; // Exit if accessed directly ?>
<p><?php echo wp_kses_post( __( 'However, working on plugins and technical support requires many hours of work. If you want to appreciate it, you can provide me a coffee.', 'sierotki' ) ); ?></p>
<p><?php echo wp_kses_post( __( 'If every plugin user did it, I could devote myself fully to working on this plugin. Thanks everyone!', 'sierotki' ) ); ?></p>
<p class="iworks-rate-center"><a href="https://ko-fi.com/iworks/?utm_source=<?php echo $args['slug']; ?>&utm_medium=widget-donate" target="_blank" class="iworks-rate-button iworks-rate-button--blue dashicons-heart"><?php echo esc_html( __( 'Provide me a coffee', 'sierotki' ) ); ?></a></p>

View File

@@ -0,0 +1,35 @@
<?php defined( 'ABSPATH' ) || exit; // Exit if accessed directly ?>
<p>
<?php
echo wp_kses_post(
__( 'Do you have a technical problem? Please contact us. We will be happy to help you. Or maybe you have an idea for a new feature? Please let us know about it by filling the support form. We will try to add it!', 'sierotki' )
);
?>
</p>
<p>
<?php
echo wp_kses_post(
sprintf(
/* translators: %1$s: open anchor tag, %2$s: close anchor tag, %3$s: open anchor tag, %4$s: close anchor tag */
__( 'Please %1$scheck our FAQ%2$s before adding a thread with technical problem. If you do not find help there, %3$scheck support forum%4$s for similar problems.', 'sierotki' ),
'<a href="' . $args['url'] . '#faq" target="_blank">',
'</a>',
'<a href="' . $args['support_url'] . '" target="_blank">',
'</a>'
)
);
?>
</p>
<p class="iworks-rate-center">
<a href="<?php echo $args['support_url']; ?>" target="_blank" class="iworks-rate-button iworks-rate-button--blue" ><?php echo esc_html( __( 'Get help', 'sierotki' ) ); ?></a>
</p>
<p>
<?php
echo wp_kses_post(
__( 'Do you like our plugin? Could you rate him? Please let us know what you think about our plugin. It is important that we can develop this tool. Thank you for all the ratings, reviews and donates.', 'sierotki' )
);
?>
</p>
<p class="iworks-rate-center">
<a href="<?php echo add_query_arg( 'rate', '5', $args['support_url'] . '/reviews/' ); ?>#new-post" target="_blank" class="iworks-rate-button iworks-rate-button--blue" ><?php echo esc_html( __( 'Add review', 'sierotki' ) ); ?></a>
</p>