Sync plugins from current page

Signed-off-by: Adrian Nöthlich <git@promasu.tech>
This commit is contained in:
2019-09-11 19:08:46 +02:00
parent 85d41e4216
commit 8515ff9587
1847 changed files with 505469 additions and 0 deletions

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,63 @@
jQuery(document).ready(function () {
// Check setting page
if (jQuery('.wp-statistics-settings').length) {
var current_tab = getParameterValue('tab');
if (current_tab) {
enableTab(current_tab);
}
jQuery('.wp-statistics-settings ul.tabs li').click(function () {
var tab_id = jQuery(this).attr('data-tab');
enableTab(tab_id);
});
}
// Check the Condition Require Setting Api
function wp_statistics_check_condition_view_option(selector, field) {
jQuery(document).on("change", selector, function (e) {
e.preventDefault();
let option_field = jQuery(field);
if (this.checked) {
option_field.show("slow");
} else {
option_field.hide("slow");
option_field.find("input[type=checkbox]").prop('checked', false);
}
});
}
// Check the visitor log is checked
wp_statistics_check_condition_view_option("input[name=wps_visitors]", "#visitors_log_tr");
// Check the Spam List
wp_statistics_check_condition_view_option("input[name=wps_referrerspam]", "tr.referrerspam_field");
/**
* Get Parameter value
* @param name
* @returns {*}
*/
function getParameterValue(name) {
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (results) {
return results[1];
}
}
/**
* Enable Tab
* @param tab_id
*/
function enableTab(tab_id) {
jQuery('.wp-statistics-settings ul.tabs li').removeClass('current');
jQuery('.wp-statistics-settings .tab-content').removeClass('current');
jQuery("[data-tab=" + tab_id + "]").addClass('current');
jQuery("#" + tab_id).addClass('current');
if (jQuery('#wp-statistics-settings-form').length) {
var click_url = jQuery(location).attr('href') + '&tab=' + tab_id;
jQuery('#wp-statistics-settings-form').attr('action', click_url).submit();
}
}
});

View File

@@ -0,0 +1,75 @@
/*
Function to handle the loading of widget content
*/
function wp_statistics_get_widget_contents(widget, container_id) {
var data = {
'action': 'wp_statistics_get_widget_contents',
'widget': widget,
'format': 'dashboard'
};
container = jQuery("#" + container_id);
if (container.is(':visible')) {
jQuery.ajax({
url: ajaxurl,
type: 'post',
data: data,
datatype: 'json',
})
.always(function (result) {
// Take the returned result and add it to the DOM.
jQuery("#" + container_id).html("").html(result);
})
.fail(function (result) {
// If we failed for some reason, like a timeout, try again.
container.html(wp_statistics_loading_image);
wp_statistics_get_widget_contents(widget, container_id);
});
}
}
function wp_statistics_refresh_widget() {
var container_id = this.id.replace('_refresh_button', '');
container_id = container_id.replace('-widget', '-div');
var widget = container_id.replace('wp-statistics-', '');
widget = widget.replace('-div', '');
widget = widget.replace('-', '.');
container = jQuery("#" + container_id);
if (container.is(':visible')) {
container.html(wp_statistics_loading_image);
wp_statistics_get_widget_contents(widget, container_id);
}
return false;
}
function wp_statistics_refresh_on_toggle_widget() {
if (this.value.substring(0, 14) != 'wp-statistics-') {
return;
}
var container_id = this.value.replace('-widget', '-div');
var widget = container_id.replace('wp-statistics-', '');
widget = widget.replace('-div', '');
widget = widget.replace('-', '.');
wp_statistics_get_widget_contents(widget, container_id);
}
function wp_statistics_goto_more() {
var widget = this.id;
if (wp_statistics_destinations[widget] !== undefined) {
window.location.href = wp_statistics_destinations[widget];
}
return false;
}

View File

@@ -0,0 +1,66 @@
/*
Function to handle the loading of widget content
*/
function wp_statistics_get_widget_contents(widget, container_id) {
var data = {
'action': 'wp_statistics_get_widget_contents',
'widget': widget,
'page-id': wp_statistics_current_id,
};
container = jQuery("#" + container_id);
if (container.is(':visible')) {
jQuery.ajax({
url: ajaxurl,
type: 'post',
data: data,
datatype: 'json',
})
.always(function (result) {
// Take the returned result and add it to the DOM.
jQuery("#" + container_id).html("").html(result);
})
.fail(function (result) {
// If we failed for some reason, like a timeout, try again.
container.html(wp_statistics_loading_image);
wp_statistics_get_widget_contents(widget, container_id);
});
}
}
function wp_statistics_refresh_widget() {
var container_id = 'wp-statistics-page-div';
var widget = 'page';
container = jQuery("#" + container_id);
container.html(wp_statistics_loading_image);
wp_statistics_get_widget_contents(widget, container_id);
return false;
}
function wp_statistics_refresh_on_toggle_widget() {
if (this.value != 'wp_statistics_editor_meta_box') {
return;
}
var container_id = 'wp-statistics-page-div';
var widget = 'page';
wp_statistics_get_widget_contents(widget, container_id);
}
function wp_statistics_goto_more() {
var widget = this.id;
if (wp_statistics_destinations[widget] !== undefined) {
window.location.href = wp_statistics_destinations[widget] + wp_statistics_current_id;
}
return false;
}

View File

@@ -0,0 +1,69 @@
/*
Function to handle the loading of widget content
*/
function wp_statistics_get_widget_contents(widget, container_id) {
var data = {
'action': 'wp_statistics_get_widget_contents',
'widget': widget,
};
container = jQuery("#" + container_id);
if (container.is(':visible')) {
jQuery.ajax({
url: ajaxurl,
type: 'post',
data: data,
datatype: 'json',
})
.always(function (result) {
// Take the returned result and add it to the DOM.
jQuery("#" + container_id).html("").html(result);
})
.fail(function (result) {
// If we failed for some reason, like a timeout, try again.
container.html(wp_statistics_loading_image);
wp_statistics_get_widget_contents(widget, container_id);
});
}
}
function wp_statistics_refresh_widget() {
var widget = this.id.replace('wps_', '');
widget = widget.replace('_refresh_button', '');
container_id = widget.replace('.', '_') + '_postbox';
container = jQuery("#" + container_id);
if (container.is(':visible')) {
container.html(wp_statistics_loading_image);
wp_statistics_get_widget_contents(widget, container_id);
}
return false;
}
function wp_statistics_refresh_on_toggle_widget() {
if (this.value.substring(0, 4) != 'wps_') {
return;
}
var container_id = this.value.replace('wps_', '');
var widget = container_id.replace('_postbox', '');
wp_statistics_get_widget_contents(widget, container_id);
}
function wp_statistics_goto_more() {
var widget = this.id;
if (wp_statistics_destinations[widget] !== undefined) {
window.location.href = wp_statistics_destinations[widget];
}
return false;
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,101 @@
(function() {
jQuery( document ).on( 'tinymce-editor-setup', function( event, editor ) {
editor.addButton( 'wp_statistic_tc_button', {
text: '',
tooltip: editor.getLang('wp_statistic_tinymce_plugin.insert'),
icon: 'icon-statistic dashicons-chart-pie',
onclick: function() {
editor.windowManager.open({
title: editor.getLang('wp_statistic_tinymce_plugin.insert'),
minWidth: 500,
minHeight: 480,
body: [
{
type: 'listbox',
name: 'stat',
label: editor.getLang('wp_statistic_tinymce_plugin.stat'),
'values': [
{text: editor.getLang('wp_statistic_tinymce_plugin.usersonline'), value: 'usersonline'},
{text: editor.getLang('wp_statistic_tinymce_plugin.visits'), value: 'visits'},
{text: editor.getLang('wp_statistic_tinymce_plugin.visitors'), value: 'visitors'},
{text: editor.getLang('wp_statistic_tinymce_plugin.pagevisits'), value: 'pagevisits'},
{text: editor.getLang('wp_statistic_tinymce_plugin.searches'), value: 'searches'},
{text: editor.getLang('wp_statistic_tinymce_plugin.postcount'), value: 'postcount'},
{text: editor.getLang('wp_statistic_tinymce_plugin.pagecount'), value: 'pagecount'},
{text: editor.getLang('wp_statistic_tinymce_plugin.commentcount'), value: 'commentcount'},
{text: editor.getLang('wp_statistic_tinymce_plugin.spamcount'), value: 'spamcount'},
{text: editor.getLang('wp_statistic_tinymce_plugin.usercount'), value: 'usercount'},
{text: editor.getLang('wp_statistic_tinymce_plugin.postaverage'), value: 'postaverage'},
{text: editor.getLang('wp_statistic_tinymce_plugin.commentaverage'), value: 'commentaverage'},
{text: editor.getLang('wp_statistic_tinymce_plugin.useraverage'), value: 'useraverage'},
{text: editor.getLang('wp_statistic_tinymce_plugin.lpd'), value: 'lpd'},
{text: editor.getLang('wp_statistic_tinymce_plugin.referrer'), value: 'referrer'},
]
},
{
type : 'container',
html : '<div class="wp-statistic-mce-desc">' + editor.getLang('wp_statistic_tinymce_plugin.help_stat') + ' </div>'
},
{
type: 'listbox',
name: 'time',
label: editor.getLang('wp_statistic_tinymce_plugin.time'),
'values': [
{text: editor.getLang('wp_statistic_tinymce_plugin.se'), value: '0'},
{text: editor.getLang('wp_statistic_tinymce_plugin.today'), value: 'today'},
{text: editor.getLang('wp_statistic_tinymce_plugin.yesterday'), value: 'yesterday'},
{text: editor.getLang('wp_statistic_tinymce_plugin.week'), value: 'week'},
{text: editor.getLang('wp_statistic_tinymce_plugin.month'), value: 'month'},
{text: editor.getLang('wp_statistic_tinymce_plugin.year'), value: 'year'},
{text: editor.getLang('wp_statistic_tinymce_plugin.total'), value: 'total'}
]
},
{
type : 'container',
html : '<div class="wp-statistic-mce-desc">' + editor.getLang('wp_statistic_tinymce_plugin.help_time') + '</div>'
},
{
type: 'textbox',
name: 'provider',
label: editor.getLang('wp_statistic_tinymce_plugin.provider'),
},
{
type : 'container',
html : '<div class="wp-statistic-mce-desc">' + editor.getLang('wp_statistic_tinymce_plugin.help_provider') + '</div>'
},
{
type: 'textbox',
name: 'format',
label: editor.getLang('wp_statistic_tinymce_plugin.format'),
},
{
type : 'container',
html : '<div class="wp-statistic-mce-desc">' + editor.getLang('wp_statistic_tinymce_plugin.help_format') + '</div>'
},
{
type: 'textbox',
name: 'id',
label: editor.getLang('wp_statistic_tinymce_plugin.id'),
},
{
type : 'container',
html : '<div class="wp-statistic-mce-desc">' + editor.getLang('wp_statistic_tinymce_plugin.help_id') + '</div>'
},
],
onsubmit: function( e ) {
var wp_statistice_shortcode = '[wpstatistics stat=' + e.data.stat;
if(e.data.time !=='0') {wp_statistice_shortcode +=' time=' + e.data.time;}
var wp_statistic_type = ["provider", "format", "id"];
wp_statistic_type.forEach(function(entry) {
if(e.data[entry] !=='') {
wp_statistice_shortcode +=' ' + entry + '=' + e.data[entry];
}
});
wp_statistice_shortcode +=']';
editor.insertContent(wp_statistice_shortcode);
}
});
}
});
});
})();