-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.4.1 - Fixed non existing function (early) call for some 3rd party p…
…lugins.
- Loading branch information
0 parents
commit 637ce7b
Showing
28 changed files
with
1,600 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/** | ||
* Add Polylang support for Customizer | ||
* | ||
* @link https://richardev.com | ||
* @since 1.4.1 | ||
* @package Polylang_Customizer | ||
* | ||
* @wordpress-plugin | ||
* Plugin Name: Add Polylang support for Customizer | ||
* Plugin URI: https://wordpress.org/plugins/add-polylang-support-for-customizer | ||
* Description: This plugin adds Polylang support for Customizer. | ||
* Version: 1.4.1 | ||
* Author: richardev | ||
* Author URI: https://richardev.com | ||
* License: GPL-2.0+ | ||
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt | ||
* Text Domain: apsfc | ||
* Domain Path: /languages | ||
*/ | ||
|
||
// If this file is called directly, abort. | ||
if (!defined('WPINC')) { | ||
die; | ||
} | ||
|
||
if (!defined('POLYLANG_VERSION')) { | ||
function apsfc_error_notice__error() | ||
{ | ||
$class = 'notice notice-error'; | ||
$message = __('<strong>Polylang</strong> plugin must be activated for <strong>Add Polylang support for Customizer</strong> plugin to work. Please <a href="' . admin_url('plugins.php') . '">activate it</a> now!', 'sample-text-domain'); | ||
|
||
printf('<div class="%1$s"><p>%2$s</p></div>', esc_attr($class), $message); | ||
} | ||
add_action('admin_notices', 'apsfc_error_notice__error'); | ||
} else { | ||
/** | ||
* Currently plugin version. | ||
* Start at version 1.0.2 and use SemVer - https://semver.org | ||
* Rename this for your plugin and update it as you release new versions. | ||
*/ | ||
define('APSFC_VERSION', '1.4.1'); | ||
define('APSFC_BASENAME', plugin_basename(__FILE__)); | ||
|
||
require_once plugin_dir_path(__FILE__) . '/includes/class-apsfc.php'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php // Silence is golden |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* | ||
*/ | ||
/* global wp, jQuery */ | ||
/* exported PluginCustomizer */ | ||
var PSPolyLang = (function( api, $ ) { | ||
'use strict'; | ||
|
||
var component = { | ||
data: { | ||
url: null, | ||
languages: null, | ||
current_language: null, | ||
} | ||
}; | ||
|
||
/** | ||
* Initialize functionality. | ||
* | ||
* @param {object} args Args. | ||
* @param {string} args.url Preview URL. | ||
* @returns {void} | ||
*/ | ||
component.init = function init( pll ) { | ||
_.extend(component.data, pll ); | ||
if (!pll || !pll.url || !pll.languages || !pll.current_language ) { | ||
throw new Error( 'Missing args' ); | ||
} | ||
|
||
api.bind( 'ready', function(){ | ||
api.previewer.previewUrl.set( pll.url ); | ||
|
||
var languages = pll.languages; | ||
var current_language = pll.current_language; | ||
var current_language_name = ''; | ||
|
||
var html = '<span style="position:relative;left:38px;margin-right:5px;top:2.5px;margin-left:5px;">' + pcLangTrans + ': </span>'; | ||
html += '<select id="pll-language-select" style="position:relative; left: 35px; top: 1px; padding: 4px 1px;width: 50px;">'; | ||
for (var i = 0; i < languages.length; i++) { | ||
var language = languages[i]; | ||
var selected = (language.slug === current_language) ? 'selected=""' : ''; | ||
current_language_name = (language.slug === current_language) ? language.name.substr(0, 3) : 'Eng'; | ||
html += '<option ' + selected + ' value="' + language.slug + '">' + language.name.substr(0, 3) + '</option>'; | ||
} | ||
html += '</select>'; | ||
$(html).prependTo('#customize-header-actions'); | ||
|
||
|
||
$('body').on('change', '#pll-language-select', function () { | ||
var language = $(this).val(); | ||
var old_url = window.location.href; | ||
window.location.href = updateQueryStringParameter(window.location.href, 'lang', language); | ||
}); | ||
}); | ||
|
||
function updateQueryStringParameter(uri, key, value) { | ||
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i"); | ||
var separator = uri.indexOf('?') !== -1 ? "&" : "?"; | ||
if (uri.match(re)) { | ||
return uri.replace(re, '$1' + key + "=" + value + '$2'); | ||
} else { | ||
return uri + separator + key + "=" + value; | ||
} | ||
} | ||
}; | ||
|
||
return component; | ||
} ( wp.customize, jQuery ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php // Silence is golden |
Oops, something went wrong.