- Subida a producción de la maqueta (II)
- Limpieza git-svn-id: https://192.168.0.254/svn/Proyectos.ASong2U_Web/trunk@7 cd1a4ea2-8c7f-e448-aada-19d1fee9e1d6
BIN
wp-content/login-logo.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
192
wp-content/plugins/login-logo/login-logo.php
Normal file
@ -0,0 +1,192 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: Login Logo
|
||||
Description: Drop a PNG file named <code>login-logo.png</code> into your <code>wp-content</code> directory. This simple plugin takes care of the rest, with zero configuration. Transparent backgrounds work best. Crop it tight, with a width of 312 pixels, for best results.
|
||||
Version: 0.6
|
||||
License: GPL
|
||||
Plugin URI: http://txfx.net/wordpress-plugins/login-logo/
|
||||
Author: Mark Jaquith
|
||||
Author URI: http://coveredwebservices.com/
|
||||
|
||||
==========================================================================
|
||||
|
||||
Copyright 2011-2012 Mark Jaquith
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
class CWS_Login_Logo_Plugin {
|
||||
static $instance;
|
||||
const cutoff = 312;
|
||||
var $logo_locations;
|
||||
var $logo_location;
|
||||
var $width = 0;
|
||||
var $height = 0;
|
||||
var $original_width;
|
||||
var $original_height;
|
||||
var $logo_size;
|
||||
var $logo_file_exists;
|
||||
|
||||
public function __construct() {
|
||||
self::$instance = $this;
|
||||
add_action( 'login_head', array( $this, 'login_head' ) );
|
||||
}
|
||||
|
||||
public function init() {
|
||||
global $blog_id;
|
||||
$this->logo_locations = array();
|
||||
if ( is_multisite() && function_exists( 'get_current_site' ) ) {
|
||||
// First, see if there is one for this specific site (blog)
|
||||
$this->logo_locations['site'] = array(
|
||||
'path' => WP_CONTENT_DIR . '/login-logo-site-' . $blog_id . '.png',
|
||||
'url' => $this->maybe_ssl( WP_CONTENT_URL . '/login-logo-site-' . $blog_id . '.png' )
|
||||
);
|
||||
|
||||
// Next, we see if there is one for this specific network
|
||||
$site = get_current_site(); // Site = Network? Ugh.
|
||||
if ( $site && isset( $site->id ) ) {
|
||||
$this->logo_locations['network'] = array(
|
||||
'path' => WP_CONTENT_DIR . '/login-logo-network-' . $site->id . '.png',
|
||||
'url' => $this->maybe_ssl( WP_CONTENT_URL . '/login-logo-network-' . $site->id . '.png' )
|
||||
);
|
||||
}
|
||||
}
|
||||
// Finally, we do a global lookup
|
||||
$this->logo_locations['global'] = array(
|
||||
'path' => WP_CONTENT_DIR . '/login-logo.png',
|
||||
'url' => $this->maybe_ssl( WP_CONTENT_URL . '/login-logo.png' )
|
||||
);
|
||||
}
|
||||
|
||||
private function maybe_ssl( $url ) {
|
||||
if ( is_ssl() )
|
||||
$url = preg_replace( '#^http://#', 'https://', $url );
|
||||
return $url;
|
||||
}
|
||||
|
||||
private function logo_file_exists() {
|
||||
if ( ! isset( $this->logo_file_exists ) ) {
|
||||
foreach ( $this->logo_locations as $location ) {
|
||||
if ( file_exists( $location['path'] ) ) {
|
||||
$this->logo_file_exists = true;
|
||||
$this->logo_location = $location;
|
||||
break;
|
||||
} else {
|
||||
$this->logo_file_exists = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return !! $this->logo_file_exists;
|
||||
}
|
||||
|
||||
private function get_location( $what = '' ) {
|
||||
if ( $this->logo_file_exists() ) {
|
||||
if ( 'path' == $what || 'url' == $what )
|
||||
return $this->logo_location[$what];
|
||||
else
|
||||
return $this->logo_location;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function get_width() {
|
||||
$this->get_logo_size();
|
||||
return absint( $this->width );
|
||||
}
|
||||
|
||||
private function get_height() {
|
||||
$this->get_logo_size();
|
||||
return absint( $this->height );
|
||||
}
|
||||
|
||||
private function get_original_width() {
|
||||
$this->get_logo_size();
|
||||
return absint( $this->original_width );
|
||||
}
|
||||
|
||||
private function get_original_height() {
|
||||
$this->get_logo_size();
|
||||
return absint( $this->original_height );
|
||||
}
|
||||
|
||||
private function get_logo_size() {
|
||||
if ( !$this->logo_file_exists() )
|
||||
return false;
|
||||
if ( !$this->logo_size ) {
|
||||
if ( $sizes = getimagesize( $this->get_location( 'path' ) ) ) {
|
||||
$this->logo_size = $sizes;
|
||||
$this->width = $sizes[0];
|
||||
$this->height = $sizes[1];
|
||||
$this->original_height = $this->height;
|
||||
$this->original_width = $this->width;
|
||||
if ( $this->width > self::cutoff ) {
|
||||
// Use CSS 3 scaling
|
||||
$ratio = $this->height / $this->width;
|
||||
$this->height = ceil( $ratio * self::cutoff );
|
||||
$this->width = self::cutoff;
|
||||
}
|
||||
} else {
|
||||
$this->logo_file_exists = false;
|
||||
}
|
||||
}
|
||||
return array( $this->width, $this->height );
|
||||
}
|
||||
|
||||
private function css3( $rule, $value ) {
|
||||
foreach ( array( '', '-o-', '-webkit-', '-khtml-', '-moz-', '-ms-' ) as $prefix ) {
|
||||
echo $prefix . $rule . ': ' . $value . '; ';
|
||||
}
|
||||
}
|
||||
|
||||
public function login_headerurl() {
|
||||
return trailingslashit( get_bloginfo( 'url' ) );
|
||||
}
|
||||
|
||||
public function login_head() {
|
||||
$this->init();
|
||||
if ( !$this->logo_file_exists() )
|
||||
return;
|
||||
add_filter( 'login_headerurl', array( $this, 'login_headerurl' ) );
|
||||
?>
|
||||
<!-- Login Logo plugin for WordPress: http://txfx.net/wordpress-plugins/login-logo/ -->
|
||||
<style type="text/css">
|
||||
.login h1 a {
|
||||
background: url(<?php echo esc_url_raw( $this->get_location( 'url' ) ); ?>) no-repeat top center;
|
||||
width: <?php echo self::cutoff; ?>px;
|
||||
height: <?php echo $this->get_height(); ?>px;
|
||||
margin-left: 8px;
|
||||
padding-bottom: 16px;
|
||||
<?php
|
||||
if ( self::cutoff < $this->get_original_width() )
|
||||
$this->css3( 'background-size', 'contain' );
|
||||
else
|
||||
$this->css3( 'background-size', 'auto' );
|
||||
?>
|
||||
}
|
||||
</style>
|
||||
<?php if ( self::cutoff < $this->get_width() ) { ?>
|
||||
<!--[if lt IE 9]>
|
||||
<style type="text/css">
|
||||
height: <?php echo $this->get_original_height() + 3; ?>px;
|
||||
</style>
|
||||
<![endif]-->
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Bootstrap
|
||||
new CWS_Login_Logo_Plugin;
|
||||
86
wp-content/plugins/login-logo/readme.txt
Normal file
@ -0,0 +1,86 @@
|
||||
=== Login Logo ===
|
||||
Contributors: markjaquith
|
||||
Donate link: http://txfx.net/wordpress-plugins/donate
|
||||
Tags: customize, login, login screen, logo, custom logo
|
||||
Requires at least: 3.3
|
||||
Tested up to: 3.4
|
||||
Stable tag: 0.6
|
||||
|
||||
Customize the logo on the WP login screen by simply dropping a file named login-logo.png into your WP content directory. CSS is automatic!
|
||||
|
||||
== Description ==
|
||||
|
||||
This plugin allows you to customize the logo on the WordPress login screen. There is zero configuration. You just drop the logo file into your WordPress content directory, named `login-logo.png` and this plugin takes over.
|
||||
|
||||
Note that you should use a transparent background on the PNG image, crop it tightly (no padding pixels) and use a width of exactly 312 pixels for best results. Wider images will be downscaled in modern browsers, but it isn't recommended to rely on that.
|
||||
|
||||
This plugin also works in the `mu-plugins` directory.
|
||||
|
||||
== Installation ==
|
||||
|
||||
1. [Click here](http://coveredwebservices.com/wp-plugin-install/?plugin=login-logo) to install and activate.
|
||||
|
||||
2. Create a PNG image with a transparent background, tightly cropped, with a recommended width of 312 pixels.
|
||||
|
||||
3. Upload the PNG image to your WordPress content directory (`/wp-content/`, by default), and name the file `login-logo.png`.
|
||||
|
||||
4. If you have a multisite install with more than one network, you can also use `login-logo-network-{NETWORK ID}.png` to assign a different login logo to each network.
|
||||
|
||||
5. If you have a multisite install, you can also use `login-logo-site-{$blog_id}.png` to assign a different login logo to each site.
|
||||
|
||||
6. Done! The login screen will now use your logo.
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
1. A login screen with a custom logo
|
||||
|
||||
2. A source image
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
= Why does my image look strange in IE or an outdated browser? =
|
||||
|
||||
Your image is probably too wide. Wide images are scaled down in IE 9 or other modern browsers, but not in older browsers. Use an image that is no more than 312 pixels wide.
|
||||
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 0.6 =
|
||||
* You can provide `login-logo-site-{$blog_id}.png` to have a different logo per multisite site.
|
||||
* Support for WordPress 3.4
|
||||
* Changed the ideal image width to 312 pixels, and instituted a tighter crop policy.
|
||||
|
||||
= 0.5 =
|
||||
* Support for WordPress 3.3
|
||||
* Fix a bug in CSS resizing of oversized images
|
||||
|
||||
= 0.4 =
|
||||
* Use HTTPS if `is_ssl()` on the login page.
|
||||
|
||||
= 0.3 =
|
||||
* The login logo now links to your site, instead of WordPress.org
|
||||
* If you don't have a custom login logo, the plugin does nothing.
|
||||
* You can provide `login-logo-network-{NETWORK ID}.png` to have a different logo per multisite network.
|
||||
|
||||
= 0.2 =
|
||||
* Do not use `background-size` unless the image is more than 326 pixels
|
||||
|
||||
= 0.1 =
|
||||
* Original version
|
||||
|
||||
== Upgrade Notice ==
|
||||
|
||||
= 0.6 =
|
||||
Upgrade now for WordPress 3.4 support! Also adds the ability to set a custom logo per site on a network.
|
||||
|
||||
= 0.5 =
|
||||
Upgrade immediately or the plugin will not work in WordPress 3.3!
|
||||
|
||||
= 0.4 =
|
||||
Adds support for SSL
|
||||
|
||||
= 0.3 =
|
||||
Makes the logo link to your site instead of WordPress.org! Support for per-network logos.
|
||||
|
||||
= 0.2 =
|
||||
Upgrade now to avoid stretching small images.
|
||||
BIN
wp-content/plugins/login-logo/screenshot-1.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
wp-content/plugins/login-logo/screenshot-2.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
@ -0,0 +1,62 @@
|
||||
# Translation of the WordPress plugin Private BuddyPress 1.0 by Dennis Morhardt.
|
||||
# Copyright (C) 2010 Dennis Morhardt
|
||||
# This file is distributed under the same license as the Private BuddyPress package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Private BuddyPress 1.0\n"
|
||||
"Report-Msgid-Bugs-To: http://wordpress.org/tag/private-buddypress\n"
|
||||
"POT-Creation-Date: 2010-09-20 09:28+0000\n"
|
||||
"PO-Revision-Date: 2010-09-20 11:28+0100\n"
|
||||
"Last-Translator: Dennis Morhardt <info@dennismorhardt.de>\n"
|
||||
"Language-Team: Dennis Morhardt <info@dennismorhardt.de>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Poedit-Language: German\n"
|
||||
"X-Poedit-Country: GERMANY\n"
|
||||
"X-Poedit-SourceCharset: utf-8\n"
|
||||
|
||||
#: private-buddypress.php:51
|
||||
msgid "BuddyPress Protection"
|
||||
msgstr "Schutz der BuddyPress-Seiten"
|
||||
|
||||
#: private-buddypress.php:144
|
||||
msgid "Exclude from protection"
|
||||
msgstr "Ausnahmen vom Schutz"
|
||||
|
||||
#: private-buddypress.php:146
|
||||
msgid "Front page"
|
||||
msgstr "Startseite"
|
||||
|
||||
#: private-buddypress.php:147
|
||||
msgid "Blog pages (posts, archives and non-buddypress pages)"
|
||||
msgstr "Blogseiten (Artikel, Archive und normale statische Seiten)"
|
||||
|
||||
#: private-buddypress.php:148
|
||||
msgid "Registration"
|
||||
msgstr "Registrierung"
|
||||
|
||||
#. Plugin Name of the plugin/theme
|
||||
msgid "Private BuddyPress"
|
||||
msgstr "Privates BuddyPress"
|
||||
|
||||
#. Plugin URI of the plugin/theme
|
||||
msgid "http://bp-tutorials.de/"
|
||||
msgstr "http://bp-tutorials.de/"
|
||||
|
||||
#. Description of the plugin/theme
|
||||
msgid "Protect your BuddyPress Installation from strangers. Only registered users will be allowed to view the installation."
|
||||
msgstr "Schütze Deine BuddyPress-Installation vor Unbekannten. Nur angemeldete Benutzer können Deine Seite aufrufen."
|
||||
|
||||
#. Author of the plugin/theme
|
||||
msgid "Dennis Morhardt"
|
||||
msgstr "Dennis Morhardt"
|
||||
|
||||
#. Author URI of the plugin/theme
|
||||
msgid "http://www.dennismorhardt.de/"
|
||||
msgstr "http://www.dennismorhardt.de/"
|
||||
|
||||
#~ msgid "Blog pages"
|
||||
#~ msgstr "Blogseiten (Artikel, Archive und Nicht-BuddyPress-Seiten)"
|
||||
@ -0,0 +1,59 @@
|
||||
# Translation of the WordPress plugin Private BuddyPress 1.0.2 by Dennis Morhardt.
|
||||
# Copyright (C) 2010 Dennis Morhardt
|
||||
# This file is distributed under the same license as the Private BuddyPress package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Private BuddyPress 1.0.2\n"
|
||||
"Report-Msgid-Bugs-To: http://wordpress.org/tag/private-buddypress\n"
|
||||
"POT-Creation-Date: 2010-09-20 09:28+0000\n"
|
||||
"PO-Revision-Date: 2011-01-23 23:55+0100\n"
|
||||
"Last-Translator: Dennis Morhardt <info@dennismorhardt.de>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Poedit-Language: Hebrew\n"
|
||||
"X-Poedit-Country: ISRAEL\n"
|
||||
|
||||
#: private-buddypress.php:51
|
||||
msgid "BuddyPress Protection"
|
||||
msgstr "הגנת BuddyPress"
|
||||
|
||||
#: private-buddypress.php:144
|
||||
msgid "Exclude from protection"
|
||||
msgstr "השמט מהגנה"
|
||||
|
||||
#: private-buddypress.php:146
|
||||
msgid "Front page"
|
||||
msgstr "דף ראשי"
|
||||
|
||||
#: private-buddypress.php:147
|
||||
msgid "Blog pages (posts, archives and non-buddypress pages)"
|
||||
msgstr "דפי בלוג (פוסטים, ארכיבים ושאר דפים שאינם שייכים ל-BuddyPress )"
|
||||
|
||||
#: private-buddypress.php:148
|
||||
msgid "Registration"
|
||||
msgstr "רישום"
|
||||
|
||||
#. Plugin Name of the plugin/theme
|
||||
msgid "Private BuddyPress"
|
||||
msgstr "Private BuddyPress"
|
||||
|
||||
#. Plugin URI of the plugin/theme
|
||||
msgid "http://bp-tutorials.de/"
|
||||
msgstr "http://bp-tutorials.de/"
|
||||
|
||||
#. Description of the plugin/theme
|
||||
msgid "Protect your BuddyPress Installation from strangers. Only registered users will be allowed to view the installation."
|
||||
msgstr "הגן על התקנת BuddyPress שלך מזרים. רק משתמשים רשומים יוכלו לצפות באתר."
|
||||
|
||||
#. Author of the plugin/theme
|
||||
msgid "Dennis Morhardt"
|
||||
msgstr "Dennis Morhardt"
|
||||
|
||||
#. Author URI of the plugin/theme
|
||||
msgid "http://www.dennismorhardt.de/"
|
||||
msgstr "http://www.dennismorhardt.de/"
|
||||
|
||||
@ -0,0 +1,59 @@
|
||||
# Translation of the WordPress plugin Private BuddyPress 1.0.4 by Dennis Morhardt.
|
||||
# Copyright (C) 2011 Dennis Morhardt
|
||||
# This file is distributed under the same license as the Private BuddyPress package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Private BuddyPress 1.0.4\n"
|
||||
"Report-Msgid-Bugs-To: http://wordpress.org/tag/private-buddypress\n"
|
||||
"POT-Creation-Date: 2010-09-20 09:28+0000\n"
|
||||
"PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: private-buddypress.php:51
|
||||
msgid "BuddyPress Protection"
|
||||
msgstr ""
|
||||
|
||||
#: private-buddypress.php:144
|
||||
msgid "Exclude from protection"
|
||||
msgstr ""
|
||||
|
||||
#: private-buddypress.php:146
|
||||
msgid "Front page"
|
||||
msgstr ""
|
||||
|
||||
#: private-buddypress.php:147
|
||||
msgid "Blog pages (posts, archives and non-buddypress pages)"
|
||||
msgstr ""
|
||||
|
||||
#: private-buddypress.php:148
|
||||
msgid "Registration"
|
||||
msgstr ""
|
||||
|
||||
#. Plugin Name of the plugin/theme
|
||||
msgid "Private BuddyPress"
|
||||
msgstr ""
|
||||
|
||||
#. Plugin URI of the plugin/theme
|
||||
msgid "http://bp-tutorials.de/"
|
||||
msgstr ""
|
||||
|
||||
#. Description of the plugin/theme
|
||||
msgid ""
|
||||
"Protect your BuddyPress Installation from strangers. Only registered users "
|
||||
"will be allowed to view the installation."
|
||||
msgstr ""
|
||||
|
||||
#. Author of the plugin/theme
|
||||
msgid "Dennis Morhardt"
|
||||
msgstr ""
|
||||
|
||||
#. Author URI of the plugin/theme
|
||||
msgid "http://www.dennismorhardt.de/"
|
||||
msgstr ""
|
||||
204
wp-content/plugins/private-buddypress/private-buddypress.php
Normal file
@ -0,0 +1,204 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: Private BuddyPress
|
||||
* Description: Protect your BuddyPress Installation from strangers. Only registered users will be allowed to view the installation.
|
||||
* Author: Dennis Morhardt
|
||||
* Author URI: http://www.dennismorhardt.de/
|
||||
* Plugin URI: http://bp-tutorials.de/
|
||||
* Version: 1.0.4
|
||||
* Text Domain: private-buddypress
|
||||
* Domain Path: /languages
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
define('PRIVATE_BUDDYPRESS_VERSION', '1.0');
|
||||
|
||||
class PrivateBuddyPress {
|
||||
var $options;
|
||||
var $dbVersion;
|
||||
|
||||
function PrivateBuddyPress() {
|
||||
// Run action
|
||||
do_action('pbp_init');
|
||||
|
||||
// Load options
|
||||
$this->options = get_option('private_buddypress');
|
||||
$this->dbVersion = get_option('private_buddypress_version');
|
||||
|
||||
// Load textdomain
|
||||
load_plugin_textdomain('private-buddypress', 'languages', dirname(plugin_basename(__FILE__)) . '/languages');
|
||||
|
||||
// Add admin options
|
||||
add_action('admin_init', array($this, 'AdminInit'));
|
||||
|
||||
// Add login redirect function
|
||||
add_action('wp', array($this, 'LoginRedirect'), 1);
|
||||
}
|
||||
|
||||
function AdminInit() {
|
||||
// Add settings section
|
||||
add_settings_section('private-buddypress', __('BuddyPress Protection', 'private-buddypress'), array($this, 'AdminOptions'), 'privacy');
|
||||
add_action('load-options.php', array($this, 'SaveAdminOptions'));
|
||||
|
||||
// Run action
|
||||
do_action('pbp_admin_init');
|
||||
}
|
||||
|
||||
function Install() {
|
||||
// Check if a existing installation
|
||||
if ( PRIVATE_BUDDYPRESS_VERSION == get_option( 'private_buddypress_version' ) )
|
||||
return;
|
||||
|
||||
// Default options
|
||||
$options = new stdClass();
|
||||
$options->exclude = new stdClass();
|
||||
$options->exclude->homepage = false;
|
||||
$options->exclude->registration = false;
|
||||
$options->exclude->blogpages = false;
|
||||
|
||||
// Add or update options to database
|
||||
update_option('private_buddypress', $options);
|
||||
update_option('private_buddypress_version', PRIVATE_BUDDYPRESS_VERSION);
|
||||
}
|
||||
|
||||
function IsBuddyPressFeed() {
|
||||
// Get BuddyPress
|
||||
global $bp;
|
||||
|
||||
// Default value
|
||||
$isBuddyPressFeed = false;
|
||||
|
||||
// Check if the current BuddyPress page is a feed
|
||||
if ( $bp->current_action == 'feed' || $bp->action_variables[0] == 'feed' )
|
||||
$isBuddyPressFeed = true;
|
||||
|
||||
// Return false if no BuddyPress feed has been called
|
||||
return apply_filters('pbp_is_buddypress_feed', $isBuddyPressFeed);
|
||||
}
|
||||
|
||||
function ProtectBlogFeeds() {
|
||||
// Default value
|
||||
$protectBlogFeeds = false;
|
||||
|
||||
// If blog pages should be protect, add protection to the feeds
|
||||
if ( is_feed() && false == $this->options->exclude->blogpages )
|
||||
$protection = true;
|
||||
|
||||
// Filter and return the value
|
||||
return apply_filters('pbp_protect_blog_feeds', $protection);
|
||||
}
|
||||
|
||||
function LoginRedirect() {
|
||||
// Get current position
|
||||
$redirect_to = apply_filters('pbp_redirect_to_after_login', $_SERVER['REQUEST_URI']);
|
||||
|
||||
// Check if user is logged in
|
||||
if ( false == is_user_logged_in() ):
|
||||
// Run action
|
||||
do_action('pbp_login_redirect');
|
||||
|
||||
// Check if current page is a feed
|
||||
if ( $this->ProtectBlogFeeds() || $this->IsBuddyPressFeed() ):
|
||||
// Try to get saved login credentials
|
||||
$credentials = array(
|
||||
'user_login' => $_SERVER['PHP_AUTH_USER'],
|
||||
'user_password' => $_SERVER['PHP_AUTH_PW']
|
||||
);
|
||||
|
||||
// Send headers for authentication
|
||||
if ( is_wp_error( wp_signon( $credentials ) ) ):
|
||||
header('WWW-Authenticate: Basic realm="' . get_option('blogtitle') . '"');
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
die('<h2>You need to be logged in to view this feed!</h2>');
|
||||
endif;
|
||||
// Redirect to login page if for current page a is required
|
||||
elseif ( $this->LoginRequired() ):
|
||||
$loginPage = apply_filters('pbp_redirect_login_page', get_option('siteurl') . '/wp-login.php?redirect_to=' . $redirect_to, $redirect_to);
|
||||
wp_redirect($loginPage);
|
||||
exit;
|
||||
endif;
|
||||
endif;
|
||||
}
|
||||
|
||||
function LoginRequired() {
|
||||
// No login required if homepage is excluded
|
||||
if ( true == $this->options->exclude->homepage && is_front_page() )
|
||||
return false;
|
||||
|
||||
// No login required if registration is excluded
|
||||
if ( true == $this->options->exclude->registration && ( bp_is_register_page() || bp_is_activation_page() ) )
|
||||
return false;
|
||||
|
||||
// No login required if blog pages are excluded
|
||||
if ( true == $this->options->exclude->blogpages && bp_is_blog_page() )
|
||||
return false;
|
||||
|
||||
// Login required
|
||||
return apply_filters('pbp_login_required_check', true);
|
||||
}
|
||||
|
||||
function SaveAdminOptions() {
|
||||
// Check for plausibility
|
||||
if ( 'yes' != $_POST["bp_protection_options"] )
|
||||
return;
|
||||
|
||||
// Exclude homepage from protection
|
||||
if ( '1' == $_POST["bp_protection_exclude_home"] )
|
||||
$this->options->exclude->homepage = true;
|
||||
else
|
||||
$this->options->exclude->homepage = false;
|
||||
|
||||
// Exclude registration from protection
|
||||
if ( '1' == $_POST["bp_protection_exclude_registration"] )
|
||||
$this->options->exclude->registration = true;
|
||||
else
|
||||
$this->options->exclude->registration = false;
|
||||
|
||||
// Exclude blog pages from protection
|
||||
if ( '1' == $_POST["bp_protection_exclude_blogpages"] )
|
||||
$this->options->exclude->blogpages = true;
|
||||
else
|
||||
$this->options->exclude->blogpages = false;
|
||||
|
||||
// Save options
|
||||
update_option('private_buddypress', apply_filters('pbp_pre_options', $this->options));
|
||||
|
||||
// Run action
|
||||
do_action('pbp_save_options');
|
||||
}
|
||||
|
||||
function AdminOptions() { ?>
|
||||
<table class="form-table">
|
||||
<tr valign="top">
|
||||
<th scope="row"><?php _e('Exclude from protection', 'private-buddypress'); ?></th>
|
||||
<td>
|
||||
<label for="bp_protection_exclude_home"><input name="bp_protection_exclude_home" id="bp_protection_exclude_home" value="1" <?php checked(true, $this->options->exclude->homepage); ?> type="checkbox"> <?php _e('Front page', 'private-buddypress'); ?></label><br />
|
||||
<label for="bp_protection_exclude_blogpages"><input name="bp_protection_exclude_blogpages" id="bp_protection_exclude_blogpages" value="1" <?php checked(true, $this->options->exclude->blogpages); ?> type="checkbox"> <?php _e('Blog pages (posts, archives and non-buddypress pages)', 'private-buddypress'); ?></label><br />
|
||||
<label for="bp_protection_exclude_registration"><input name="bp_protection_exclude_registration" id="bp_protection_exclude_registration" value="1" <?php checked(true, $this->options->exclude->registration); ?> type="checkbox"> <?php _e('Registration', 'private-buddypress'); ?></label>
|
||||
<input name="bp_protection_options" id="bp_protection_options" type="hidden" value="yes" />
|
||||
<?php do_action('pbp_options_page'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php }
|
||||
}
|
||||
|
||||
// Add activation hook
|
||||
register_activation_hook(__FILE__, array('PrivateBuddyPress', 'Install'));
|
||||
|
||||
// Init the plugin at WordPress startup
|
||||
$t = new PrivateBuddyPress();
|
||||
122
wp-content/plugins/private-buddypress/readme.txt
Normal file
@ -0,0 +1,122 @@
|
||||
=== Private BuddyPress ===
|
||||
Contributors: GIGALinux
|
||||
Tags: buddypress, protection, privacy, private, protect, hide, community
|
||||
Requires at least: 3.0, BuddyPress 1.2
|
||||
Tested up to: 3.1, BuddyPress 1.3
|
||||
Stable tag: 1.0.4
|
||||
|
||||
Protect your BuddyPress Installation from strangers. Only registered users will be allowed to view the installation.
|
||||
|
||||
== Description ==
|
||||
|
||||
Protect your BuddyPress Installation from strangers. Only registered users will be allowed to view the installation and all other users will be redirected to the login page. Users attempting to view blog content via RSS are also authenticated via HTTP Auth.
|
||||
|
||||
You can exclude the registration, the homepage and blog pages (e.g. posts, archives and non-buddypress pages) from protection. In combination with the plugin 'Invitation Code Checker' your installation stays private but the registration is for users with a special password open.
|
||||
|
||||
The plugin includes a German and Hebrew (thanks to gstupp) translation.
|
||||
|
||||
== Installation ==
|
||||
|
||||
Use the automatic plugin installation in the backand or install the plugin manuell:
|
||||
|
||||
1. Upload `private-buddypress` to the `/wp-content/plugins/` directory
|
||||
2. Activate the plugin through the 'Plugins' menu in WordPress
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
= Can I exclude the homepage, the registration or blog pages from protection? =
|
||||
|
||||
Yes, you can define the excludes on the settings page unter `Settings -> Privacy`.
|
||||
|
||||
= Can I change the URL where non-loggedin users are being redirected? =
|
||||
|
||||
Yes, currently you need to write a filter function in your functions.php.
|
||||
|
||||
`function redirect_nonloggedin_users($current_uri, $redirect_to) {
|
||||
// Redirect users to the homepage
|
||||
// Caution! Exclude the homepage from 'Private BuddyPress' options
|
||||
// to avoid redirection loops!
|
||||
return get_option('siteurl') . '/?from=' . $redirect_to;
|
||||
}
|
||||
|
||||
add_filter('pbp_redirect_login_page', 'redirect_nonloggedin_users', 10, 2);`
|
||||
|
||||
= Can I exclude e.g. the blog directory from protection? =
|
||||
|
||||
Yes, you need to write a filter:
|
||||
|
||||
`function make_blog_directory_visible($visibility) {
|
||||
global $bp;
|
||||
|
||||
if ( bp_is_directory() && $bp->current_component == $bp->blogs->slug )
|
||||
return false;
|
||||
|
||||
return $visibility;
|
||||
}
|
||||
|
||||
add_filter('pbp_login_required_check', 'make_blog_directory_visible');`
|
||||
|
||||
= Are there other actions or filters? =
|
||||
|
||||
Yes, currently in Private Buddypress are existing 5 actions:
|
||||
|
||||
* **pbp_init**: Fired when Private BuddyPress is initialised
|
||||
* **pbp_admin_init**: Fired when Private BuddyPress in the admin area is initialised
|
||||
* **pbp_login_redirect**: Fired when the users is not logged in and is being redirected to the login page or when it is a feed asked for a password
|
||||
* **pbp_save_options**: Fired when the options of Private BuddyPress has been changed
|
||||
* **pbp_options_page**: Fired on the options page to added more fields for custom options
|
||||
|
||||
Also in Private BuddyPress are existing 6 filters:
|
||||
|
||||
* **pbp_is_buddypress_feed**: Boolean value if the current page is a BuddyPress feed
|
||||
* **pbp_redirect_to_after_login**: Called URI from where the users came from
|
||||
* **pbp_redirect_login_page**: URI where nonloggedin users are being redirected
|
||||
* **pbp_login_required_check**: Boolean value if for the current page a login is needed
|
||||
* **pbp_pre_options**: Object with the new options before they saved
|
||||
* **pbp_protect_blog_feeds**: Boolean value if blog feeds should be protected
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
1. Settings page, you can find it under `Settings -> Privacy`
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 1.0.4 =
|
||||
* Fixed: If blog pages excluded from protection, don't protect the feeds
|
||||
* Added: New filter: 'pbp_protect_blog_feeds'
|
||||
* Added: Hebrew translation, thanks to gstupp
|
||||
|
||||
= 1.0.3 =
|
||||
* Fixed: Options no longer disappear suddenly
|
||||
* Fixed: BuddyPress feeds are now protected
|
||||
* Added: Filters and actions, see FAQ for more information
|
||||
|
||||
= 1.0.2 =
|
||||
* Fixed: Saving optings haven't worked correctly
|
||||
* Added: Blog pages (e.g. posts, archives, non-buddypress pages) can now be excluded from protection
|
||||
|
||||
= 1.0.1 =
|
||||
* Notification update for users who downloaded the plugin before it was finished
|
||||
* Fixed: Some fatal PHP errors
|
||||
* Added: Plugin is now translatable
|
||||
* Added: German translation
|
||||
|
||||
= 1.0 =
|
||||
* First release
|
||||
|
||||
== Upgrade Notice ==
|
||||
|
||||
= 1.0.4 =
|
||||
Blog feeds are no longer protected if blog pages are excluded from the protection. Added also a Hebrew translation.
|
||||
|
||||
= 1.0.3 =
|
||||
Options no longer disappear suddenly and BuddyPress feeds are now protected. Update is recommended.
|
||||
|
||||
= 1.0.2 =
|
||||
Saving options now work correctly and added an option to exclude normal blog pages (e.g. posts, archives, non-buddypress pages) from protection.
|
||||
|
||||
= 1.0.1 =
|
||||
Notification update for users who downloaded the plugin before it was finished. Fixed the fatal PHP error and added translations.
|
||||
|
||||
= 1.0 =
|
||||
First release
|
||||
BIN
wp-content/plugins/private-buddypress/screenshot-1.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
@ -1,818 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Admin functions
|
||||
*/
|
||||
add_action('init', 'wpcf_admin_init_hook');
|
||||
add_action('admin_menu', 'wpcf_admin_menu_hook');
|
||||
if (defined('DOING_AJAX')) {
|
||||
require_once WPCF_INC_ABSPATH . '/ajax.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* admin_init hook.
|
||||
*/
|
||||
function wpcf_admin_init_hook() {
|
||||
wpcf_types_plugin_redirect();
|
||||
}
|
||||
|
||||
/**
|
||||
* admin_menu hook.
|
||||
*/
|
||||
function wpcf_admin_menu_hook() {
|
||||
add_menu_page('Types', 'Types', 'manage_options', 'wpcf',
|
||||
'wpcf_admin_menu_summary',
|
||||
WPCF_RES_RELPATH . '/images/logo-16.png');
|
||||
|
||||
// Custom fields
|
||||
$hook = add_submenu_page('wpcf', __('Custom Fields', 'wpcf'),
|
||||
__('Custom Fields', 'wpcf'), 'manage_options', 'wpcf-cf',
|
||||
'wpcf_admin_menu_summary');
|
||||
wpcf_admin_plugin_help($hook, 'wpcf-cf');
|
||||
add_action('load-' . $hook, 'wpcf_admin_menu_summary_hook');
|
||||
// Custom types and tax
|
||||
$hook = add_submenu_page('wpcf', __('Custom Types and Taxonomies', 'wpcf'),
|
||||
__('Custom Types and Taxonomies', 'wpcf'), 'manage_options',
|
||||
'wpcf-ctt', 'wpcf_admin_menu_summary_ctt');
|
||||
add_action('load-' . $hook, 'wpcf_admin_menu_summary_ctt_hook');
|
||||
wpcf_admin_plugin_help($hook, 'wpcf-ctt');
|
||||
// Import/Export
|
||||
$hook = add_submenu_page('wpcf', __('Import/Export', 'wpcf'),
|
||||
__('Import/Export', 'wpcf'), 'manage_options', 'wpcf-import-export',
|
||||
'wpcf_admin_menu_import_export');
|
||||
add_action('load-' . $hook, 'wpcf_admin_menu_import_export_hook');
|
||||
wpcf_admin_plugin_help($hook, 'wpcf-import-export');
|
||||
// Custom Fields Control
|
||||
$hook = add_submenu_page('wpcf', __('Custom Fields Control', 'wpcf'),
|
||||
__('Custom Fields Control', 'wpcf'), 'manage_options',
|
||||
'wpcf-custom-fields-control',
|
||||
'wpcf_admin_menu_custom_fields_control');
|
||||
add_action('load-' . $hook, 'wpcf_admin_menu_custom_fields_control_hook');
|
||||
wpcf_admin_plugin_help($hook, 'wpcf-custom-fields-control');
|
||||
// Settings
|
||||
$hook = add_submenu_page('wpcf', __('Settings', 'wpcf'),
|
||||
__('Settings', 'wpcf'), 'manage_options', 'wpcf-custom-settings',
|
||||
'wpcf_admin_menu_settings');
|
||||
add_action('load-' . $hook, 'wpcf_admin_menu_settings_hook');
|
||||
|
||||
if (isset($_GET['page'])) {
|
||||
switch ($_GET['page']) {
|
||||
case 'wpcf-edit':
|
||||
$title = isset($_GET['group_id']) ? __('Edit Group', 'wpcf') : __('Add New Group',
|
||||
'wpcf');
|
||||
$hook = add_submenu_page('wpcf', $title, $title,
|
||||
'manage_options', 'wpcf-edit',
|
||||
'wpcf_admin_menu_edit_fields');
|
||||
add_action('load-' . $hook, 'wpcf_admin_menu_edit_fields_hook');
|
||||
wpcf_admin_plugin_help($hook, 'wpcf-edit');
|
||||
break;
|
||||
|
||||
case 'wpcf-edit-type':
|
||||
$title = isset($_GET['wpcf-post-type']) ? __('Edit Custom Post Type',
|
||||
'wpcf') : __('Add New Custom Post Type', 'wpcf');
|
||||
$hook = add_submenu_page('wpcf', $title, $title,
|
||||
'manage_options', 'wpcf-edit-type',
|
||||
'wpcf_admin_menu_edit_type');
|
||||
add_action('load-' . $hook, 'wpcf_admin_menu_edit_type_hook');
|
||||
wpcf_admin_plugin_help($hook, 'wpcf-edit-type');
|
||||
break;
|
||||
|
||||
case 'wpcf-edit-tax':
|
||||
$title = isset($_GET['wpcf-tax']) ? __('Edit Taxonomy', 'wpcf') : __('Add New Taxonomy',
|
||||
'wpcf');
|
||||
$hook = add_submenu_page('wpcf', $title, $title,
|
||||
'manage_options', 'wpcf-edit-tax',
|
||||
'wpcf_admin_menu_edit_tax');
|
||||
add_action('load-' . $hook, 'wpcf_admin_menu_edit_tax_hook');
|
||||
wpcf_admin_plugin_help($hook, 'wpcf-edit-tax');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if migration from other plugin is needed
|
||||
if (class_exists('Acf') || defined('CPT_VERSION')) {
|
||||
$hook = add_submenu_page('wpcf', __('Migration', 'wpcf'),
|
||||
__('Migration', 'wpcf'), 'manage_options', 'wpcf-migration',
|
||||
'wpcf_admin_menu_migration');
|
||||
add_action('load-' . $hook, 'wpcf_admin_menu_migration_hook');
|
||||
wpcf_admin_plugin_help($hook, 'wpcf-migration');
|
||||
}
|
||||
|
||||
// Introduction
|
||||
$hook = add_submenu_page('wpcf', __('Help', 'wpcf'),
|
||||
__('Help', 'wpcf'), 'manage_options', 'wpcf-help',
|
||||
'wpcf_admin_menu_introduction');
|
||||
wpcf_admin_plugin_help($hook, 'wpcf');
|
||||
add_action('load-' . $hook, 'wpcf_admin_menu_introduction_hook');
|
||||
|
||||
// remove the repeating Types submenu
|
||||
remove_submenu_page('wpcf', 'wpcf');
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu page hook.
|
||||
*/
|
||||
function wpcf_admin_menu_introduction_hook() {
|
||||
do_action('wpcf_admin_page_init');
|
||||
wp_enqueue_style('wpcf-introduction', WPCF_RES_RELPATH . '/css/basic.css',
|
||||
array(), WPCF_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu page display.
|
||||
*/
|
||||
function wpcf_admin_menu_introduction() {
|
||||
require_once WPCF_INC_ABSPATH . '/introduction.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu page hook.
|
||||
*/
|
||||
function wpcf_admin_menu_summary_hook() {
|
||||
do_action('wpcf_admin_page_init');
|
||||
wp_enqueue_script('wpcf-fields-edit', WPCF_RES_RELPATH . '/js/basic.js',
|
||||
array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable'),
|
||||
WPCF_VERSION);
|
||||
wp_enqueue_style('wpcf-fields-edit', WPCF_RES_RELPATH . '/css/basic.css',
|
||||
array(), WPCF_VERSION);
|
||||
wpcf_admin_load_collapsible();
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu page display.
|
||||
*/
|
||||
function wpcf_admin_menu_summary() {
|
||||
echo wpcf_add_admin_header(__('Custom Fields', 'wpcf'));
|
||||
require_once WPCF_INC_ABSPATH . '/fields.php';
|
||||
require_once WPCF_INC_ABSPATH . '/fields-list.php';
|
||||
$to_display = wpcf_admin_fields_get_fields();
|
||||
if (!empty($to_display)) {
|
||||
add_action('wpcf_groups_list_table_after', 'wpcf_admin_promotional_text');
|
||||
}
|
||||
wpcf_admin_fields_list();
|
||||
echo wpcf_add_admin_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu page hook.
|
||||
*/
|
||||
function wpcf_admin_menu_edit_fields_hook() {
|
||||
do_action('wpcf_admin_page_init');
|
||||
wp_enqueue_script('wpcf-fields-edit',
|
||||
WPCF_EMBEDDED_RES_RELPATH . '/js/basic.js',
|
||||
array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable'),
|
||||
WPCF_VERSION);
|
||||
wp_enqueue_style('wpcf-fields-edit',
|
||||
WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION);
|
||||
wp_enqueue_script('wpcf-form-validation',
|
||||
WPCF_EMBEDDED_RES_RELPATH . '/js/'
|
||||
. 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
|
||||
WPCF_VERSION);
|
||||
wp_enqueue_script('wpcf-form-validation-additional',
|
||||
WPCF_EMBEDDED_RES_RELPATH . '/js/'
|
||||
. 'jquery-form-validation/additional-methods.min.js',
|
||||
array('jquery'), WPCF_VERSION);
|
||||
wp_enqueue_style('wpcf-scroll',
|
||||
WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/css/scroll.css');
|
||||
wp_enqueue_script('wpcf-scrollbar',
|
||||
WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/js/scrollbar.js',
|
||||
array('jquery'));
|
||||
wp_enqueue_script('wpcf-mousewheel',
|
||||
WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/js/mousewheel.js',
|
||||
array('wpcf-scrollbar'));
|
||||
add_action('admin_footer', 'wpcf_admin_fields_form_js_validation');
|
||||
require_once WPCF_INC_ABSPATH . '/fields.php';
|
||||
require_once WPCF_INC_ABSPATH . '/fields-form.php';
|
||||
$form = wpcf_admin_fields_form();
|
||||
wpcf_form('wpcf_form_fields', $form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu page display.
|
||||
*/
|
||||
function wpcf_admin_menu_edit_fields() {
|
||||
if (isset($_GET['group_id'])) {
|
||||
$title = __('Edit Group', 'wpcf');
|
||||
} else {
|
||||
$title = __('Add New Group', 'wpcf');
|
||||
}
|
||||
echo wpcf_add_admin_header($title);
|
||||
$form = wpcf_form('wpcf_form_fields');
|
||||
echo '<br /><form method="post" action="" class="wpcf-fields-form '
|
||||
. 'wpcf-form-validate" onsubmit="';
|
||||
echo 'if (jQuery(\'#wpcf-group-name\').val() == \'' . __('Enter group title',
|
||||
'wpcf') . '\') { jQuery(\'#wpcf-group-name\').val(\'\'); }';
|
||||
echo 'if (jQuery(\'#wpcf-group-description\').val() == \'' . __('Enter a description for this group',
|
||||
'wpcf') . '\') { jQuery(\'#wpcf-group-description\').val(\'\'); }';
|
||||
echo 'jQuery(\'.wpcf-forms-set-legend\').each(function(){
|
||||
if (jQuery(this).val() == \'' . __('Enter field name',
|
||||
'wpcf') . '\') {
|
||||
jQuery(this).val(\'\');
|
||||
}
|
||||
if (jQuery(this).next().val() == \'' . __('Enter field slug',
|
||||
'wpcf') . '\') {
|
||||
jQuery(this).next().val(\'\');
|
||||
}
|
||||
if (jQuery(this).next().next().val() == \'' . __('Describe this field',
|
||||
'wpcf') . '\') {
|
||||
jQuery(this).next().next().val(\'\');
|
||||
}
|
||||
});';
|
||||
echo '">';
|
||||
echo $form->renderForm();
|
||||
echo '</form>';
|
||||
echo wpcf_add_admin_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu page hook.
|
||||
*/
|
||||
function wpcf_admin_menu_summary_ctt_hook() {
|
||||
do_action('wpcf_admin_page_init');
|
||||
wp_enqueue_script('wpcf-ctt', WPCF_RES_RELPATH . '/js/basic.js',
|
||||
array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable'),
|
||||
WPCF_VERSION);
|
||||
wp_enqueue_style('wpcf-ctt', WPCF_RES_RELPATH . '/css/basic.css', array(),
|
||||
WPCF_VERSION);
|
||||
wpcf_admin_load_collapsible();
|
||||
require_once WPCF_INC_ABSPATH . '/custom-types.php';
|
||||
require_once WPCF_INC_ABSPATH . '/custom-taxonomies.php';
|
||||
require_once WPCF_INC_ABSPATH . '/custom-types-taxonomies-list.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu page display.
|
||||
*/
|
||||
function wpcf_admin_menu_summary_ctt() {
|
||||
echo wpcf_add_admin_header(__('Custom Post Types and Taxonomies', 'wpcf'));
|
||||
$to_display_posts = get_option('wpcf-custom-types', array());
|
||||
$to_display_tax = get_option('wpcf-custom-taxonomies', array());
|
||||
if (!empty($to_display_posts) || !empty($to_display_tax)) {
|
||||
add_action('wpcf_types_tax_list_table_after',
|
||||
'wpcf_admin_promotional_text');
|
||||
}
|
||||
wpcf_admin_ctt_list();
|
||||
echo wpcf_add_admin_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu page hook.
|
||||
*/
|
||||
function wpcf_admin_menu_edit_type_hook() {
|
||||
do_action('wpcf_admin_page_init');
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-types.php';
|
||||
require_once WPCF_INC_ABSPATH . '/custom-types-form.php';
|
||||
require_once WPCF_INC_ABSPATH . '/post-relationship.php';
|
||||
wp_enqueue_script('wpcf-fields-edit', WPCF_RES_RELPATH . '/js/basic.js',
|
||||
array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable'),
|
||||
WPCF_VERSION);
|
||||
wp_enqueue_style('wpcf-type-edit', WPCF_RES_RELPATH . '/css/basic.css',
|
||||
array(), WPCF_VERSION);
|
||||
wp_enqueue_script('wpcf-form-validation',
|
||||
WPCF_RES_RELPATH . '/js/'
|
||||
. 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
|
||||
WPCF_VERSION);
|
||||
wp_enqueue_script('wpcf-form-validation-additional',
|
||||
WPCF_RES_RELPATH . '/js/'
|
||||
. 'jquery-form-validation/additional-methods.min.js',
|
||||
array('jquery'), WPCF_VERSION);
|
||||
add_action('admin_footer', 'wpcf_admin_types_form_js_validation');
|
||||
wpcf_post_relationship_init();
|
||||
$form = wpcf_admin_custom_types_form();
|
||||
wpcf_form('wpcf_form_types', $form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu page display.
|
||||
*/
|
||||
function wpcf_admin_menu_edit_type() {
|
||||
if (isset($_GET['wpcf-post-type'])) {
|
||||
$title = __('Edit Custom Post Type', 'wpcf');
|
||||
} else {
|
||||
$title = __('Add New Custom Post Type', 'wpcf');
|
||||
}
|
||||
echo wpcf_add_admin_header($title);
|
||||
$form = wpcf_form('wpcf_form_types');
|
||||
echo '<br /><form method="post" action="" class="wpcf-types-form '
|
||||
. 'wpcf-form-validate">';
|
||||
echo $form->renderForm();
|
||||
echo '</form>';
|
||||
echo wpcf_add_admin_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu page hook.
|
||||
*/
|
||||
function wpcf_admin_menu_edit_tax_hook() {
|
||||
do_action('wpcf_admin_page_init');
|
||||
wp_enqueue_script('wpcf-tax-edit', WPCF_RES_RELPATH . '/js/basic.js',
|
||||
array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable'),
|
||||
WPCF_VERSION);
|
||||
wp_enqueue_style('wpcf-tax-edit', WPCF_RES_RELPATH . '/css/basic.css',
|
||||
array(), WPCF_VERSION);
|
||||
wp_enqueue_script('wpcf-form-validation',
|
||||
WPCF_RES_RELPATH . '/js/'
|
||||
. 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
|
||||
WPCF_VERSION);
|
||||
wp_enqueue_script('wpcf-form-validation-additional',
|
||||
WPCF_RES_RELPATH . '/js/'
|
||||
. 'jquery-form-validation/additional-methods.min.js',
|
||||
array('jquery'), WPCF_VERSION);
|
||||
add_action('admin_footer', 'wpcf_admin_tax_form_js_validation');
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-taxonomies.php';
|
||||
require_once WPCF_INC_ABSPATH . '/custom-taxonomies-form.php';
|
||||
$form = wpcf_admin_custom_taxonomies_form();
|
||||
wpcf_form('wpcf_form_tax', $form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu page display.
|
||||
*/
|
||||
function wpcf_admin_menu_edit_tax() {
|
||||
if (isset($_GET['wpcf-tax'])) {
|
||||
$title = __('Edit Taxonomy', 'wpcf');
|
||||
} else {
|
||||
$title = __('Add New Taxonomy', 'wpcf');
|
||||
}
|
||||
echo wpcf_add_admin_header($title);
|
||||
$form = wpcf_form('wpcf_form_tax');
|
||||
echo '<br /><form method="post" action="" class="wpcf-tax-form '
|
||||
. 'wpcf-form-validate">';
|
||||
echo $form->renderForm();
|
||||
echo '</form>';
|
||||
echo wpcf_add_admin_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu page hook.
|
||||
*/
|
||||
function wpcf_admin_menu_import_export_hook() {
|
||||
do_action('wpcf_admin_page_init');
|
||||
wp_enqueue_style('wpcf-import-export', WPCF_RES_RELPATH . '/css/basic.css',
|
||||
array(), WPCF_VERSION);
|
||||
require_once WPCF_INC_ABSPATH . '/fields.php';
|
||||
require_once WPCF_INC_ABSPATH . '/import-export.php';
|
||||
if (extension_loaded('simplexml') && isset($_POST['export'])
|
||||
&& wp_verify_nonce($_POST['_wpnonce'], 'wpcf_import')) {
|
||||
wpcf_admin_export_data();
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu page display.
|
||||
*/
|
||||
function wpcf_admin_menu_import_export() {
|
||||
echo wpcf_add_admin_header(__('Import/Export', 'wpcf'));
|
||||
echo '<br /><form method="post" action="" class="wpcf-import-export-form '
|
||||
. 'wpcf-form-validate" enctype="multipart/form-data">';
|
||||
echo wpcf_form_simple(wpcf_admin_import_export_form());
|
||||
echo '</form>';
|
||||
echo wpcf_add_admin_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu page hook.
|
||||
*/
|
||||
function wpcf_admin_menu_custom_fields_control_hook() {
|
||||
do_action('wpcf_admin_page_init');
|
||||
add_action('admin_head', 'wpcf_admin_custom_fields_control_js');
|
||||
add_thickbox();
|
||||
wp_enqueue_script('wpcf-fields-edit', WPCF_RES_RELPATH . '/js/basic.js',
|
||||
array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable'),
|
||||
WPCF_VERSION);
|
||||
wp_enqueue_style('wpcf-custom-fields-control',
|
||||
WPCF_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION);
|
||||
require_once WPCF_INC_ABSPATH . '/fields.php';
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
||||
require_once WPCF_INC_ABSPATH . '/fields-control.php';
|
||||
|
||||
if (isset($_REQUEST['_wpnonce'])
|
||||
&& wp_verify_nonce($_REQUEST['_wpnonce'],
|
||||
'custom_fields_control_bulk')
|
||||
&& (isset($_POST['action']) || isset($_POST['action2'])) && !empty($_POST['fields'])) {
|
||||
$action = $_POST['action'] == '-1' ? $_POST['action2'] : $_POST['action'];
|
||||
wpcf_admin_custom_fields_control_bulk_actions($action);
|
||||
}
|
||||
|
||||
global $wpcf_control_table;
|
||||
$wpcf_control_table = new WPCF_Custom_Fields_Control_Table(array(
|
||||
'ajax' => true,
|
||||
'singular' => __('Custom Field', 'wpcf'),
|
||||
'plural' => __('Custom Fields', 'wpcf'),
|
||||
));
|
||||
$wpcf_control_table->prepare_items();
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu page display.
|
||||
*/
|
||||
function wpcf_admin_menu_custom_fields_control() {
|
||||
global $wpcf_control_table;
|
||||
echo wpcf_add_admin_header(__('Custom Fields Control', 'wpcf'));
|
||||
echo '<br /><form method="post" action="" id="wpcf-custom-fields-control-form" class="wpcf-custom-fields-control-form '
|
||||
. 'wpcf-form-validate" enctype="multipart/form-data">';
|
||||
echo wpcf_admin_custom_fields_control_form($wpcf_control_table);
|
||||
wp_nonce_field('custom_fields_control_bulk');
|
||||
echo '</form>';
|
||||
echo wpcf_add_admin_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu page hook.
|
||||
*/
|
||||
function wpcf_admin_menu_migration_hook() {
|
||||
do_action('wpcf_admin_page_init');
|
||||
wp_enqueue_style('wpcf-migration', WPCF_RES_RELPATH . '/css/basic.css',
|
||||
array(), WPCF_VERSION);
|
||||
wp_enqueue_script('wpcf-migration', WPCF_RES_RELPATH . '/js/basic.js',
|
||||
array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable'),
|
||||
WPCF_VERSION);
|
||||
require_once WPCF_INC_ABSPATH . '/fields.php';
|
||||
require_once WPCF_INC_ABSPATH . '/custom-types.php';
|
||||
require_once WPCF_INC_ABSPATH . '/custom-taxonomies.php';
|
||||
require_once WPCF_INC_ABSPATH . '/migration.php';
|
||||
$form = wpcf_admin_migration_form();
|
||||
wpcf_form('wpcf_form_migration', $form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu page display.
|
||||
*/
|
||||
function wpcf_admin_menu_migration() {
|
||||
echo wpcf_add_admin_header(__('Migration', 'wpcf'));
|
||||
echo '<br /><form method="post" action="" id="wpcf-migration-form" class="wpcf-migration-form '
|
||||
. 'wpcf-form-validate" enctype="multipart/form-data">';
|
||||
$form = wpcf_form('wpcf_form_migration');
|
||||
echo $form->renderForm();
|
||||
echo '</form>';
|
||||
echo wpcf_add_admin_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu page hook.
|
||||
*/
|
||||
function wpcf_admin_menu_settings_hook() {
|
||||
do_action('wpcf_admin_page_init');
|
||||
wp_enqueue_style('wpcf-migration', WPCF_RES_RELPATH . '/css/basic.css',
|
||||
array(), WPCF_VERSION);
|
||||
require_once WPCF_INC_ABSPATH . '/settings.php';
|
||||
$form = wpcf_admin_settings_form();
|
||||
wpcf_form('wpcf_form_settings', $form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu page display.
|
||||
*/
|
||||
function wpcf_admin_menu_settings() {
|
||||
echo wpcf_add_admin_header(__('Settings', 'wpcf'));
|
||||
echo '<br /><form method="post" action="" id="wpcf-settings-form" class="wpcf-settings-form '
|
||||
. 'wpcf-form-validate">';
|
||||
$form = wpcf_form('wpcf_form_settings');
|
||||
echo $form->renderForm();
|
||||
echo '</form>';
|
||||
echo wpcf_add_admin_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds typical header on admin pages.
|
||||
*
|
||||
* @param string $title
|
||||
* @param string $icon_id Custom icon
|
||||
* @return string
|
||||
*/
|
||||
function wpcf_add_admin_header($title, $icon_id = 'icon-wpcf') {
|
||||
echo "\r\n" . '<div class="wrap">
|
||||
<div id="' . $icon_id . '" class="icon32"><br /></div>
|
||||
<h2>' . $title . '</h2>' . "\r\n";
|
||||
do_action('wpcf_admin_header');
|
||||
do_action('wpcf_admin_header_' . $_GET['page']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds footer on admin pages.
|
||||
*
|
||||
* <b>Strongly recomended</b> if wpcf_add_admin_header() is called before.
|
||||
* Otherwise invalid HTML formatting will occur.
|
||||
*/
|
||||
function wpcf_add_admin_footer() {
|
||||
do_action('wpcf_admin_footer_' . $_GET['page']);
|
||||
do_action('wpcf_admin_footer');
|
||||
echo "\r\n" . '</div>' . "\r\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML formatted 'widefat' table.
|
||||
*
|
||||
* @param type $ID
|
||||
* @param type $header
|
||||
* @param type $rows
|
||||
* @param type $empty_message
|
||||
*/
|
||||
function wpcf_admin_widefat_table($ID, $header, $rows = array(),
|
||||
$empty_message = 'No results') {
|
||||
$head = '';
|
||||
$footer = '';
|
||||
foreach ($header as $key => $value) {
|
||||
$head .= '<th id="wpcf-table-' . $key . '">' . $value . '</th>' . "\r\n";
|
||||
$footer .= '<th>' . $value . '</th>' . "\r\n";
|
||||
}
|
||||
echo '<table id="' . $ID . '" class="widefat" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
' . $head . '
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
' . $footer . '
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
';
|
||||
$row = '';
|
||||
if (empty($rows)) {
|
||||
echo '<tr><td colspan="' . count($header) . '">' . $empty_message
|
||||
. '</td></tr>';
|
||||
} else {
|
||||
foreach ($rows as $row) {
|
||||
echo '<tr>';
|
||||
foreach ($row as $column_name => $column_value) {
|
||||
echo '<td class="wpcf-table-column-' . $column_name . '">';
|
||||
echo $column_value;
|
||||
echo '</td>' . "\r\n";
|
||||
}
|
||||
echo '</tr>' . "\r\n";
|
||||
}
|
||||
}
|
||||
echo '
|
||||
</tbody>
|
||||
</table>' . "\r\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves open fieldsets.
|
||||
*
|
||||
* @param type $action
|
||||
* @param type $fieldset
|
||||
*/
|
||||
function wpcf_admin_form_fieldset_save_toggle($action, $fieldset) {
|
||||
$data = get_user_meta(get_current_user_id(), 'wpcf-form-fieldsets-toggle',
|
||||
true);
|
||||
if ($action == 'open') {
|
||||
$data[$fieldset] = 1;
|
||||
} else if ($action == 'close') {
|
||||
unset($data[$fieldset]);
|
||||
}
|
||||
update_user_meta(get_current_user_id(), 'wpcf-form-fieldsets-toggle', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if fieldset is saved as open.
|
||||
*
|
||||
* @param type $fieldset
|
||||
*/
|
||||
function wpcf_admin_form_fieldset_is_collapsed($fieldset) {
|
||||
$data = get_user_meta(get_current_user_id(), 'wpcf-form-fieldsets-toggle',
|
||||
true);
|
||||
if (empty($data)) {
|
||||
return true;
|
||||
}
|
||||
return array_key_exists($fieldset, $data) ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds help on admin pages.
|
||||
*
|
||||
* @param type $contextual_help
|
||||
* @param type $screen_id
|
||||
* @param type $screen
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_admin_plugin_help($hook, $page) {
|
||||
global $wp_version;
|
||||
$call = false;
|
||||
$contextual_help = '';
|
||||
$page = $page;
|
||||
if (isset($page) && isset($_GET['page']) && $_GET['page'] == $page) {
|
||||
switch ($page) {
|
||||
case 'wpcf-cf':
|
||||
$call = 'custom_fields';
|
||||
break;
|
||||
|
||||
case 'wpcf-ctt':
|
||||
$call = 'custom_types_and_taxonomies';
|
||||
break;
|
||||
|
||||
case 'wpcf-import-export':
|
||||
$call = 'import_export';
|
||||
break;
|
||||
|
||||
case 'wpcf-edit':
|
||||
$call = 'edit_group';
|
||||
break;
|
||||
|
||||
case 'wpcf-edit-type':
|
||||
$call = 'edit_type';
|
||||
break;
|
||||
|
||||
case 'wpcf-edit-tax':
|
||||
$call = 'edit_tax';
|
||||
break;
|
||||
case 'wpcf':
|
||||
$call = 'wpcf';
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($call) {
|
||||
require_once WPCF_ABSPATH . '/help.php';
|
||||
$contextual_help = wpcf_admin_help($call, $contextual_help);
|
||||
// WP 3.3 changes
|
||||
if (version_compare($wp_version, '3.2.1', '>')) {
|
||||
set_current_screen($hook);
|
||||
$screen = get_current_screen();
|
||||
if (!is_null($screen)) {
|
||||
$args = array(
|
||||
'title' => __('Types', 'wpcf'),
|
||||
'id' => 'wpcf',
|
||||
'content' => $contextual_help,
|
||||
'callback' => false,
|
||||
);
|
||||
$screen->add_help_tab($args);
|
||||
}
|
||||
} else {
|
||||
add_contextual_help($hook, $contextual_help);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function wpcf_admin_promotional_text() {
|
||||
$promotional_text = '<div class="message updated wpcf-collapsible" style="margin-top: 50px; padding: 5px 20px;">';
|
||||
if (defined('WPV_VERSION')) { // Views active
|
||||
$promotional_text .= wpcf_admin_toggle_button('wpcf-promotional-noviews');
|
||||
$promotional_text .= '<h3>' . __('Want to display custom content easily?',
|
||||
'wpcf') . '</h3><div id="wpcf-promotional-noviews-toggle" class="wpcf-toggle-wrapper">';
|
||||
$promotional_text .= '<p style="font-size: 110%;">' . sprintf(__("%sViews%s plugin let's you create dynamic templates for single pages and complex content lists. It queries content from the database, filters it and displays in any way you choose.",
|
||||
'wpcf'),
|
||||
'<a href="http://wp-types.com/home/views-create-elegant-displays-for-your-content/" title="Views" target="_blank">',
|
||||
'</a>') . '</p>';
|
||||
$promotional_text .= '<p style="font-size: 110%;">' . __("Views is already installed in your site!",
|
||||
'wpcf') . '</p>';
|
||||
$promotional_text .= '<p style="font-size: 110%;">' . __("Next:", 'wpcf') . '</p>';
|
||||
$promotional_text .= '<ul style="margin-bottom: 20px; list-style-type:disc; list-style-position: inside; font-size: 110%;">
|
||||
<li style="margin-left:20px;"><a href="' . admin_url('edit.php?post_type=view-template') . '">' . __('Create <strong>View Templates</strong> for single pages »',
|
||||
'wpcf') . '</a></li>';
|
||||
$promotional_text .= '<li style="margin-left:20px;"><a href="' . admin_url('edit.php?post_type=view') . '">' . __('Create <strong>Views</strong> for content lists »',
|
||||
'wpcf') . '</a></li></ul>';
|
||||
$promotional_text .= sprintf(__('For tutorials and manuals, go to %shttp://wp-types.com%s',
|
||||
'wpcf'), '<a href="http://wp-types.com" target="_blank"><strong>',
|
||||
' »</strong></a>');
|
||||
} else {
|
||||
$post_types = get_post_types(array('_builtin' => false), 'objects');
|
||||
unset($post_types['wp-types-group'], $post_types['view'],
|
||||
$post_types['view-template']);
|
||||
if (count($post_types) < 1) {
|
||||
$list_post_types = __("posts, pages and custom content types",
|
||||
'wpcf');
|
||||
} else if (count($post_types) < 2) {
|
||||
$add = array_shift($post_types);
|
||||
$list_post_types = $add->label;
|
||||
} else {
|
||||
$add = array();
|
||||
foreach ($post_types as $p => $post_type) {
|
||||
$add[] = $post_type->label;
|
||||
}
|
||||
$last = array_pop($add);
|
||||
$list_post_types = sprintf(__('%s and %s', 'wpcf'),
|
||||
implode(', ', $add), $last);
|
||||
}
|
||||
$promotional_text .= wpcf_admin_toggle_button('wpcf-promotional-views');
|
||||
$promotional_text .= '<h3>' . __('Want to Build Sites Faster?', 'wpcf') . '</h3><div id="wpcf-promotional-views-toggle" class="wpcf-toggle-wrapper">'
|
||||
. '<p><strong>' . sprintf(__("%sViews%s, lets you create complex WordPress sites, quickly and easily. Instead of coding and debugging everything, let Views do the heavy lifting for you.",
|
||||
'wpcf'),
|
||||
'<a href="http://wp-types.com/home/views-create-elegant-displays-for-your-content/" target="_blank">',
|
||||
'</a>') . '</strong></p>'
|
||||
. '<p>' . __("With Views, you can:",
|
||||
'wpcf') . '</p>'
|
||||
. '<p style="margin:-5px 0 0 0; padding:0;">' . '<ul style="margin:15px 10px; list-style-type:disc; list-style-position: inside;">'
|
||||
. '<li>' . __("Create single-page templates and insert custom fields.",
|
||||
'wpcf') . '</li>'
|
||||
. '<li>' . __("Load content and display it as lists, grids, tables, sliders and more.",
|
||||
'wpcf') . '</li>'
|
||||
. '<li>' . __("Create your own widgets and place them anywhere in the theme.",
|
||||
'wpcf') . '</li>'
|
||||
. '</ul></p>'
|
||||
. '<p>' . sprintf(__("%sLearn more about Views%s", 'wpcf'),
|
||||
'<a href="http://wp-types.com/home/views-create-elegant-displays-for-your-content/" target="_blank" class="button-primary">',
|
||||
' »</a>') . '</p>'
|
||||
. '<p><br />' . __("Check out these Views tutorials:",
|
||||
'wpcf') . '</p>'
|
||||
. '<p>' . '<ul style="list-style-type:none; list-style-position: inside;">'
|
||||
. '<li style="width: 300px;float:left;"><div style="clear:both;"><div style="border:1px solid #DFDFDF; height:100px;overflow:hidden;float:left;margin-right:10px;margin-bottom:20px;"><a href="http://wp-types.com/learn/create-a-showcase-website/" target="_blank"><img style="position:relative;top:0px;" src="' . WPCF_EMBEDDED_RES_RELPATH . '/images/showcase1-150x150.jpg" /></a></div>'
|
||||
. '<strong>' . __("Showcase Site","wpcf") . '</strong><br /><span style="color: #808080;">(' . sprintf(__('%d minutes to build','wpcf'),20) . ')</span><br /><br />'
|
||||
. '<a href="http://wp-types.com/learn/create-a-showcase-website/" target="_blank">' . __('Tutorial','wpcf')
|
||||
. ' »</a>'
|
||||
. '</div></li>'
|
||||
. '<li style="width: 300px;float:left;"><div style="clear:both;"><div style="border:1px solid #DFDFDF; height:100px;overflow:hidden;float:left;margin-right:10px;margin-bottom:20px;"><a href="http://wp-types.com/learn/create-a-real-estate-wordpress-theme/" target="_blank"><img style="position:relative;top:-50px;" src="' . WPCF_EMBEDDED_RES_RELPATH . '/images/realestate-150x150.jpg" /></a></div>'
|
||||
. '<strong>' . __("Real Estate Listing","wpcf") . '</strong><br /><span style="color: #808080;">(' . sprintf(__('%d minutes to build','wpcf'),30) . ')</span><br /><br />'
|
||||
. '<a href="http://wp-types.com/learn/create-a-real-estate-wordpress-theme/" target="_blank">' . __('Tutorial','wpcf')
|
||||
. ' »</a>'
|
||||
. '</div></li>'
|
||||
. '</ul><br style="clear:both;" /><ul style="list-style-type:none; list-style-position: inside;">'
|
||||
. '<li style="width: 300px;float:left;"><div style="clear:both;"><div style="border:1px solid #DFDFDF; height:100px;overflow:hidden;float:left;margin-right:10px;margin-bottom:20px;"><a href="http://wp-types.com/learn/create-a-wordpress-magazine-theme/" target="_blank"><img style="position:relative;top:-30px;" src="' . WPCF_EMBEDDED_RES_RELPATH . '/images/magazine-final-150x150.jpg" /></a></div>'
|
||||
. '<strong>' . __("Magazine Theme","wpcf") . '</strong><br /><span style="color: #808080;">(' . sprintf(__('%d minutes to build','wpcf'),45) . ')</span><br /><br />'
|
||||
. '<a href="http://wp-types.com/learn/create-a-wordpress-magazine-theme/" target="_blank">' . __('Tutorial','wpcf')
|
||||
. ' »</a>'
|
||||
. '</div></li>'
|
||||
. '<li style="width: 300px;float:left;"><div style="clear:both;"><div style="border:1px solid #DFDFDF; height:100px;overflow:hidden;float:left;margin-right:10px;margin-bottom:20px;"><a href="http://wp-types.com/learn/wordpress-classifieds-site/" target="_blank"><img style="position:relative;top:-30px;" src="' . WPCF_EMBEDDED_RES_RELPATH . '/images/classifieds-150x150.jpg" /></a></div>'
|
||||
. '<strong>' . __("Classifieds Site","wpcf") . '</strong><br /><span style="color: #808080;">(' . sprintf(__('%d minutes to build','wpcf'),60) . ')</span><br /><br />'
|
||||
. '<a href="http://wp-types.com/learn/wordpress-classifieds-site/" target="_blank">' . __('Tutorial','wpcf')
|
||||
. ' »</a>'
|
||||
. '</div></li>'
|
||||
. '</ul></p>'
|
||||
. '<hr style="clear:both;" />'
|
||||
. '<p><br />' . __("Prefer to use PHP and code everything from scratch?",
|
||||
'wpcf') . '</p>'
|
||||
. '<p>' . sprintf(__("%sLearn the Types PHP API%s", 'wpcf'),
|
||||
'<a href="http://wp-types.com/documentation/functions/" target="_blank">',
|
||||
' »</a>') . '</p>';
|
||||
}
|
||||
$promotional_text .= '</div></div>';
|
||||
echo $promotional_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collapsible scripts.
|
||||
*/
|
||||
function wpcf_admin_load_collapsible() {
|
||||
wp_enqueue_script('wpcf-collapsible',
|
||||
WPCF_RES_RELPATH . '/js/collapsible.js', array('jquery'),
|
||||
WPCF_VERSION);
|
||||
wp_enqueue_style('wpcf-collapsible',
|
||||
WPCF_RES_RELPATH . '/css/collapsible.css', array(), WPCF_VERSION);
|
||||
$option = get_option('wpcf_toggle', array());
|
||||
if (!empty($option)) {
|
||||
$setting = 'new Array("' . implode('", "', array_keys($option)) . '")';
|
||||
wpcf_admin_add_js_settings('wpcf_collapsed', $setting);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle button.
|
||||
*
|
||||
* @param type $div_id
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_admin_toggle_button($div_id) {
|
||||
return '<a href="'
|
||||
. admin_url('admin-ajax.php?action=wpcf_ajax&wpcf_action=toggle&div='
|
||||
. $div_id . '-toggle&_wpnonce='
|
||||
. wp_create_nonce('toggle'))
|
||||
. '" id="' . $div_id
|
||||
. '" class="wpcf-collapsible-button"></a>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Various delete/deactivate content actions.
|
||||
*
|
||||
* @param type $type
|
||||
* @param type $arg
|
||||
* @param type $action
|
||||
*/
|
||||
function wpcf_admin_deactivate_content($type, $arg, $action = 'delete') {
|
||||
switch ($type) {
|
||||
case 'post_type':
|
||||
// Clean tax relations
|
||||
if ($action == 'delete') {
|
||||
$custom = get_option('wpcf-custom-taxonomies', array());
|
||||
foreach ($custom as $post_type => $data) {
|
||||
if (empty($data['supports'])) {
|
||||
continue;
|
||||
}
|
||||
if (array_key_exists($arg, $data['supports'])) {
|
||||
unset($custom[$post_type]['supports'][$arg]);
|
||||
}
|
||||
}
|
||||
update_option('wpcf-custom-taxonomies', $custom);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'taxonomy':
|
||||
// Clean post relations
|
||||
if ($action == 'delete') {
|
||||
$custom = get_option('wpcf-custom-types', array());
|
||||
foreach ($custom as $post_type => $data) {
|
||||
if (empty($data['taxonomies'])) {
|
||||
continue;
|
||||
}
|
||||
if (array_key_exists($arg, $data['taxonomies'])) {
|
||||
unset($custom[$post_type]['taxonomies'][$arg]);
|
||||
}
|
||||
}
|
||||
update_option('wpcf-custom-types', $custom);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1,743 +0,0 @@
|
||||
<?php
|
||||
require_once(WPCF_EMBEDDED_ABSPATH . '/common/visual-editor/editor-addon.class.php');
|
||||
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
|
||||
|
||||
if (defined('DOING_AJAX')) {
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/ajax.php';
|
||||
add_action('wp_ajax_wpcf_ajax', 'wpcf_ajax_embedded');
|
||||
}
|
||||
|
||||
/**
|
||||
* admin_init hook.
|
||||
*/
|
||||
function wpcf_embedded_admin_init_hook() {
|
||||
// Add callbacks for post edit pages
|
||||
add_action('load-post.php', 'wpcf_admin_post_page_load_hook');
|
||||
add_action('load-post-new.php', 'wpcf_admin_post_page_load_hook');
|
||||
|
||||
// Add callback for 'media-upload.php'
|
||||
add_filter('get_media_item_args', 'wpcf_get_media_item_args_filter');
|
||||
|
||||
// Add save_post callback
|
||||
add_action('save_post', 'wpcf_admin_save_post_hook', 10, 2);
|
||||
|
||||
// Render messages
|
||||
wpcf_show_admin_messages();
|
||||
|
||||
// Render JS settings
|
||||
add_action('admin_head', 'wpcf_admin_render_js_settings');
|
||||
|
||||
// Media insert code
|
||||
if (isset($_GET['wpcf-fields-media-insert'])
|
||||
|| (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'],
|
||||
'wpcf-fields-media-insert=1'))) {
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/file.php';
|
||||
// Add types button
|
||||
add_filter('attachment_fields_to_edit',
|
||||
'wpcf_fields_file_attachment_fields_to_edit_filter', 10, 2);
|
||||
// Add JS
|
||||
add_action('admin_head', 'wpcf_fields_file_media_admin_head');
|
||||
// Filter media TABs
|
||||
add_filter('media_upload_tabs',
|
||||
'wpcf_fields_file_media_upload_tabs_filter');
|
||||
}
|
||||
|
||||
register_post_type('wp-types-group',
|
||||
array(
|
||||
'public' => false,
|
||||
'label' => 'Types Groups',
|
||||
'can_export' => false,
|
||||
)
|
||||
);
|
||||
|
||||
add_filter('icl_custom_fields_to_be_copied',
|
||||
'wpcf_custom_fields_to_be_copied', 10, 2);
|
||||
|
||||
// WPML editor filters
|
||||
add_filter('icl_editor_cf_name', 'wpcf_icl_editor_cf_name_filter');
|
||||
add_filter('icl_editor_cf_description',
|
||||
'wpcf_icl_editor_cf_description_filter', 10, 2);
|
||||
add_filter('icl_editor_cf_style', 'wpcf_icl_editor_cf_style_filter', 10, 2);
|
||||
// Initialize translations
|
||||
if (function_exists('icl_register_string')
|
||||
&& defined('WPML_ST_VERSION')
|
||||
&& !get_option('wpcf_strings_translation_initialized', false)) {
|
||||
wpcf_admin_bulk_string_translation();
|
||||
update_option('wpcf_strings_translation_initialized', 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* save_post hook.
|
||||
*
|
||||
* @param type $post_ID
|
||||
* @param type $post
|
||||
*/
|
||||
function wpcf_admin_save_post_hook($post_ID, $post) {
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
|
||||
wpcf_admin_post_save_post_hook($post_ID, $post);
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers post procceses.
|
||||
*/
|
||||
function wpcf_admin_post_page_load_hook() {
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
|
||||
|
||||
// Get post
|
||||
if (isset($_GET['post'])) {
|
||||
$post_id = (int) $_GET['post'];
|
||||
} else if (isset($_POST['post_ID'])) {
|
||||
$post_id = (int) $_POST['post_ID'];
|
||||
} else {
|
||||
$post_id = 0;
|
||||
}
|
||||
|
||||
// Init processes
|
||||
if ($post_id) {
|
||||
$post = get_post($post_id);
|
||||
if (!empty($post)) {
|
||||
wpcf_admin_post_init($post);
|
||||
}
|
||||
} else {
|
||||
wpcf_admin_post_init();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiates/returns specific form.
|
||||
*
|
||||
* @staticvar array $wpcf_forms
|
||||
* @param type $id
|
||||
* @param type $form
|
||||
* @return array
|
||||
*/
|
||||
function wpcf_form($id, $form = array()) {
|
||||
static $wpcf_forms = array();
|
||||
if (isset($wpcf_forms[$id])) {
|
||||
return $wpcf_forms[$id];
|
||||
}
|
||||
require_once WPCF_EMBEDDED_ABSPATH . '/classes/forms.php';
|
||||
$new_form = new Enlimbo_Forms_Wpcf();
|
||||
$new_form->autoHandle($id, $form);
|
||||
$wpcf_forms[$id] = $new_form;
|
||||
return $wpcf_forms[$id];
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders form elements.
|
||||
*
|
||||
* @staticvar string $form
|
||||
* @param type $elements
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_form_simple($elements) {
|
||||
static $form = NULL;
|
||||
require_once WPCF_EMBEDDED_ABSPATH . '/classes/forms.php';
|
||||
if (is_null($form)) {
|
||||
$form = new Enlimbo_Forms_Wpcf();
|
||||
}
|
||||
return $form->renderElements($elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates form elements (simple).
|
||||
*
|
||||
* @staticvar string $form
|
||||
* @param type $elements
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_form_simple_validate(&$elements) {
|
||||
static $form = NULL;
|
||||
require_once WPCF_EMBEDDED_ABSPATH . '/classes/forms.php';
|
||||
if (is_null($form)) {
|
||||
$form = new Enlimbo_Forms_Wpcf();
|
||||
}
|
||||
$form->validate($elements);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores JS validation rules.
|
||||
*
|
||||
* @staticvar array $validation
|
||||
* @param type $element
|
||||
* @return array
|
||||
*/
|
||||
function wpcf_form_add_js_validation($element) {
|
||||
static $validation = array();
|
||||
if ($element == 'get') {
|
||||
$temp = $validation;
|
||||
$validation = array();
|
||||
return $temp;
|
||||
}
|
||||
$validation[$element['#id']] = $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders JS validation rules.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_form_render_js_validation($form = '.wpcf-form-validate',
|
||||
$echo = true) {
|
||||
// static $cache;
|
||||
// if (($echo && isset($cache[$form]['echo'])) || (!$echo && isset($cache[$form]['return']))) {
|
||||
// return '';
|
||||
// }
|
||||
$elements = wpcf_form_add_js_validation('get');
|
||||
if (empty($elements)) {
|
||||
return '';
|
||||
}
|
||||
$output = '';
|
||||
$output .= "\r\n" . '<script type="text/javascript">' . "\r\n" . '/* <![CDATA[ */'
|
||||
. "\r\n" . 'jQuery(document).ready(function(){' . "\r\n"
|
||||
. 'if (jQuery("' . $form . '").length > 0){' . "\r\n"
|
||||
. 'jQuery("' . $form . '").validate({
|
||||
errorClass: "wpcf-form-error",
|
||||
errorPlacement: function(error, element){
|
||||
error.insertBefore(element);
|
||||
},
|
||||
highlight: function(element, errorClass, validClass) {
|
||||
jQuery(element).parents(\'.collapsible\').slideDown();
|
||||
jQuery("input#publish").addClass("button-primary-disabled");
|
||||
jQuery("input#save-post").addClass("button-disabled");
|
||||
jQuery("#save-action .ajax-loading").css("visibility", "hidden");
|
||||
jQuery("#publishing-action #ajax-loading").css("visibility", "hidden");
|
||||
// jQuery.validator.defaults.highlight(element, errorClass, validClass); // Do not add class to element
|
||||
},
|
||||
unhighlight: function(element, errorClass, validClass) {
|
||||
jQuery("input#publish, input#save-post").removeClass("button-primary-disabled").removeClass("button-disabled");
|
||||
// jQuery.validator.defaults.unhighlight(element, errorClass, validClass);
|
||||
},
|
||||
});' . "\r\n";
|
||||
foreach ($elements as $id => $element) {
|
||||
if (empty($element['#validate'])) {
|
||||
continue;
|
||||
}
|
||||
if (in_array($element['#type'], array('radios'))) {
|
||||
$output .= 'jQuery(\'input:[name="' . $element['#name'] . '"]\').rules("add", {' . "\r\n";
|
||||
} else {
|
||||
$output .= 'jQuery("#' . $id . '").rules("add", {' . "\r\n";
|
||||
}
|
||||
$rules = array();
|
||||
$messages = array();
|
||||
foreach ($element['#validate'] as $method => $args) {
|
||||
if (!isset($args['value'])) {
|
||||
$args['value'] = 'true';
|
||||
}
|
||||
$rules[] = $method . ': ' . $args['value'];
|
||||
if (empty($args['message'])) {
|
||||
$args['message'] = wpcf_admin_validation_messages($method);
|
||||
}
|
||||
}
|
||||
$output .= implode(',' . "\r\n", $rules);
|
||||
if (!empty($messages)) {
|
||||
$output .= ',' . "\r\n" . 'messages: {' . "\r\n"
|
||||
. implode(',' . "\r\n", $messages) . "\r\n" . '}';
|
||||
}
|
||||
$output .= "\r\n" . '});' . "\r\n";
|
||||
}
|
||||
$output .= "\r\n" . '/* ]]> */' . "\r\n" . '}' . "\r\n" . '})' . "\r\n"
|
||||
. '</script>' . "\r\n";
|
||||
|
||||
if ($echo) {
|
||||
// $cache[$form]['echo'] = 1;
|
||||
echo $output;
|
||||
} else {
|
||||
// $cache[$form]['return'] = 1;
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* wpcf_custom_fields_to_be_copied
|
||||
*
|
||||
* Hook the copy custom fields from WPML and remove any of the fields
|
||||
* that wpcf will copy.
|
||||
*/
|
||||
function wpcf_custom_fields_to_be_copied($copied_fields, $original_post_id) {
|
||||
|
||||
// see if this is one of our fields.
|
||||
$groups = wpcf_admin_post_get_post_groups_fields(get_post($original_post_id));
|
||||
|
||||
foreach ($copied_fields as $id => $copied_field) {
|
||||
foreach ($groups as $group) {
|
||||
foreach ($group['fields'] as $field) {
|
||||
if ($copied_field == wpcf_types_get_meta_prefix($field) . $field['slug']) {
|
||||
unset($copied_fields[$id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $copied_fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds validation messages.
|
||||
*
|
||||
* @param type $method
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_admin_validation_messages($method = false) {
|
||||
$messages = array(
|
||||
'required' => __('This Field is required', 'wpcf'),
|
||||
'email' => __('Please enter a valid email address', 'wpcf'),
|
||||
'url' => __('Please enter a valid URL address', 'wpcf'),
|
||||
'date' => __('Please enter a valid date', 'wpcf'),
|
||||
'digits' => __('Please enter numeric data', 'wpcf'),
|
||||
'number' => __('Please enter numeric data', 'wpcf'),
|
||||
'alphanumeric' => __('Letters, numbers, spaces or underscores only please',
|
||||
'wpcf'),
|
||||
'nospecialchars' => __('Letters, numbers, spaces, underscores and dashes only please',
|
||||
'wpcf'),
|
||||
'rewriteslug' => __('Letters, numbers, slashes, underscores and dashes only please',
|
||||
'wpcf')
|
||||
);
|
||||
if ($method) {
|
||||
return isset($messages[$method]) ? $messages[$method] : '';
|
||||
}
|
||||
return $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds admin notice.
|
||||
*
|
||||
* @param type $message
|
||||
* @param type $class
|
||||
*/
|
||||
function wpcf_admin_message($message, $class = 'updated') {
|
||||
add_action('admin_notices',
|
||||
create_function('$a=1, $class=\'' . $class . '\', $message=\''
|
||||
. htmlentities($message, ENT_QUOTES) . '\'',
|
||||
'$screen = get_current_screen(); if (!$screen->is_network) echo "<div class=\"message $class\"><p>" . html_entity_decode($message, ENT_QUOTES) . "</p></div>";'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows stored messages.
|
||||
*/
|
||||
function wpcf_show_admin_messages() {
|
||||
$messages = get_option('wpcf-messages', array());
|
||||
$messages_for_user = isset($messages[get_current_user_id()]) ? $messages[get_current_user_id()] : array();
|
||||
if (!empty($messages_for_user)) {
|
||||
foreach ($messages_for_user as $message) {
|
||||
wpcf_admin_message($message['message'], $message['class']);
|
||||
}
|
||||
unset($messages[get_current_user_id()]);
|
||||
}
|
||||
update_option('wpcf-messages', $messages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores admin notices if redirection is performed.
|
||||
*
|
||||
* @param type $message
|
||||
* @param type $class
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_admin_message_store($message, $class = 'updated') {
|
||||
$messages = get_option('wpcf-messages', array());
|
||||
$messages[get_current_user_id()][md5($message)] = array(
|
||||
'message' => $message,
|
||||
'class' => $class
|
||||
);
|
||||
update_option('wpcf-messages', $messages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves cookie.
|
||||
*
|
||||
* @param type $data
|
||||
*/
|
||||
function wpcf_cookies_add($data) {
|
||||
if (isset($_COOKIE['wpcf'])) {
|
||||
$data = array_merge((array) $_COOKIE['wpcf'], $data);
|
||||
}
|
||||
setcookie('wpcf', $data, time() + $lifetime, COOKIEPATH, COOKIE_DOMAIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* WPML editor filter
|
||||
*
|
||||
* @param type $cf_name
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_icl_editor_cf_name_filter($cf_name) {
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
||||
$fields = wpcf_admin_fields_get_fields();
|
||||
if (empty($fields)) {
|
||||
return $cf_name;
|
||||
}
|
||||
$cf_name = substr($cf_name, 6);
|
||||
if (strpos($cf_name, WPCF_META_PREFIX) == 0) {
|
||||
$cf_name = str_replace(WPCF_META_PREFIX, '', $cf_name);
|
||||
}
|
||||
if (isset($fields[$cf_name]['name'])) {
|
||||
$cf_name = wpcf_translate('field ' . $fields[$cf_name]['id'] . ' name',
|
||||
$fields[$cf_name]['name']);
|
||||
}
|
||||
return $cf_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* WPML editor filter
|
||||
*
|
||||
* @param type $cf_name
|
||||
* @param type $description
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_icl_editor_cf_description_filter($description, $cf_name) {
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
||||
$fields = wpcf_admin_fields_get_fields();
|
||||
if (empty($fields)) {
|
||||
return $description;
|
||||
}
|
||||
$cf_name = substr($cf_name, 6);
|
||||
if (strpos($cf_name, WPCF_META_PREFIX) == 0) {
|
||||
$cf_name = str_replace(WPCF_META_PREFIX, '', $cf_name);
|
||||
}
|
||||
if (isset($fields[$cf_name]['description'])) {
|
||||
$description = wpcf_translate('field ' . $fields[$cf_name]['id'] . ' description',
|
||||
$fields[$cf_name]['description']);
|
||||
}
|
||||
|
||||
return $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* WPML editor filter
|
||||
*
|
||||
* @param type $cf_name
|
||||
* @param type $style
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_icl_editor_cf_style_filter($style, $cf_name) {
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
||||
$fields = wpcf_admin_fields_get_fields();
|
||||
|
||||
if (empty($fields)) {
|
||||
return $style;
|
||||
}
|
||||
|
||||
$cf_name = substr($cf_name, 6);
|
||||
|
||||
if (strpos($cf_name, WPCF_META_PREFIX) == 0) {
|
||||
$cf_name = str_replace(WPCF_META_PREFIX, '', $cf_name);
|
||||
}
|
||||
if (isset($fields[$cf_name]['type']) && $fields[$cf_name]['type'] == 'textarea') {
|
||||
$style = 1;
|
||||
}
|
||||
if (isset($fields[$cf_name]['type']) && $fields[$cf_name]['type'] == 'wysiwyg') {
|
||||
$style = 2;
|
||||
}
|
||||
return $style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders page head.
|
||||
*
|
||||
* @global type $pagenow
|
||||
* @param type $title
|
||||
*/
|
||||
function wpcf_admin_ajax_head($title) {
|
||||
global $pagenow;
|
||||
$hook_suffix = $pagenow;
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
|
||||
<title><?php echo $title; ?></title>
|
||||
<?php
|
||||
if (wpcf_compare_wp_version('3.2.1', '<=')) {
|
||||
wp_admin_css('global');
|
||||
}
|
||||
wp_admin_css();
|
||||
wp_admin_css('colors');
|
||||
wp_admin_css('ie');
|
||||
// do_action('admin_enqueue_scripts', $hook_suffix);
|
||||
do_action("admin_print_styles-$hook_suffix");
|
||||
do_action('admin_print_styles');
|
||||
// do_action("admin_print_scripts-$hook_suffix");
|
||||
do_action('admin_print_scripts');
|
||||
// do_action("admin_head-$hook_suffix");
|
||||
// do_action('admin_head');
|
||||
do_action('admin_head_wpcf_ajax');
|
||||
|
||||
?>
|
||||
<style type="text/css">
|
||||
html { height: auto; }
|
||||
</style>
|
||||
</head>
|
||||
<body style="padding: 20px;">
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders page footer
|
||||
*/
|
||||
function wpcf_admin_ajax_footer() {
|
||||
global $pagenow;
|
||||
do_action('admin_footer_wpcf_ajax');
|
||||
// do_action('admin_footer', '');
|
||||
// do_action('admin_print_footer_scripts');
|
||||
// do_action("admin_footer-" . $pagenow);
|
||||
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets var from $_SERVER['HTTP_REFERER'].
|
||||
*
|
||||
* @param type $var
|
||||
*/
|
||||
function wpcf_admin_get_var_from_referer($var) {
|
||||
$value = false;
|
||||
if (isset($_SERVER['HTTP_REFERER'])) {
|
||||
$parts = explode('?', $_SERVER['HTTP_REFERER']);
|
||||
if (!empty($parts[1])) {
|
||||
parse_str($parts[1], $vars);
|
||||
if (isset($vars[$var])) {
|
||||
$value = $vars[$var];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds JS settings.
|
||||
*
|
||||
* @staticvar array $settings
|
||||
* @param type $id
|
||||
* @param type $setting
|
||||
* @return string
|
||||
*/
|
||||
function wpcf_admin_add_js_settings($id, $setting = '') {
|
||||
static $settings = array();
|
||||
$settings['wpcf_nonce_ajax_callback'] = '\'' . wp_create_nonce('execute') . '\'';
|
||||
$settings['wpcf_cookiedomain'] = '\'' . $_SERVER['SERVER_NAME'] . '\'';
|
||||
$settings['wpcf_cookiepath'] = '\'' . COOKIEPATH . '\'';
|
||||
if ($id == 'get') {
|
||||
$temp = $settings;
|
||||
$settings = array();
|
||||
return $temp;
|
||||
}
|
||||
$settings[$id] = $setting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders JS settings.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_admin_render_js_settings() {
|
||||
$settings = wpcf_admin_add_js_settings('get');
|
||||
if (empty($settings)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
<?php
|
||||
foreach ($settings as $id => $setting) {
|
||||
echo 'var ' . $id . ' = ' . $setting . ';' . "\r\n";
|
||||
}
|
||||
|
||||
?>
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* wpcf_get_fields
|
||||
*
|
||||
* returns the fields handled by types
|
||||
*
|
||||
*/
|
||||
function wpcf_get_post_meta_field_names() {
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
||||
$fields = wpcf_admin_fields_get_fields();
|
||||
|
||||
$field_names = array();
|
||||
foreach ($fields as $field) {
|
||||
$field_names[] = wpcf_types_get_meta_prefix($field) . $field['slug'];
|
||||
}
|
||||
|
||||
return $field_names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces 'Insert into post' link when called from our WYSIWYG.
|
||||
*
|
||||
* @param array $args
|
||||
* @return boolean
|
||||
*/
|
||||
function wpcf_get_media_item_args_filter($args) {
|
||||
if (strpos($_SERVER['SCRIPT_NAME'], '/media-upload.php') === false) {
|
||||
return $args;
|
||||
}
|
||||
if (!empty($_COOKIE['wpcfActiveEditor'])
|
||||
&& strpos($_COOKIE['wpcfActiveEditor'], 'wpcf-wysiwyg-') !== false) {
|
||||
$args['send'] = true;
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets post.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_admin_get_edited_post() {
|
||||
if (isset($_GET['post'])) {
|
||||
$post_id = (int) $_GET['post'];
|
||||
} else if (isset($_POST['post_ID'])) {
|
||||
$post_id = (int) $_POST['post_ID'];
|
||||
} else {
|
||||
$post_id = 0;
|
||||
}
|
||||
if ($post_id) {
|
||||
return get_post($post_id);
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets post type.
|
||||
*
|
||||
* @param type $post
|
||||
* @return boolean
|
||||
*/
|
||||
function wpcf_admin_get_post_type($post) {
|
||||
if ($post) {
|
||||
$post_type = get_post_type($post);
|
||||
} else {
|
||||
if (!isset($_GET['post_type'])) {
|
||||
$post_type = 'post';
|
||||
} else if (in_array($_GET['post_type'],
|
||||
get_post_types(array('show_ui' => true)))) {
|
||||
$post_type = $_GET['post_type'];
|
||||
} else {
|
||||
$post_type = 'post';
|
||||
}
|
||||
}
|
||||
return $post_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk translation.
|
||||
*/
|
||||
function wpcf_admin_bulk_string_translation() {
|
||||
if (!function_exists('icl_register_string')) {
|
||||
return false;
|
||||
}
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-types.php';
|
||||
require_once WPCF_INC_ABSPATH . '/custom-types-form.php';
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-taxonomies.php';
|
||||
require_once WPCF_INC_ABSPATH . '/custom-taxonomies-form.php';
|
||||
|
||||
// Register groups
|
||||
$groups = wpcf_admin_fields_get_groups();
|
||||
foreach ($groups as $group_id => $group) {
|
||||
wpcf_translate_register_string('plugin Types',
|
||||
'group ' . $group_id . ' name', $group['name']);
|
||||
if (isset($group['description'])) {
|
||||
wpcf_translate_register_string('plugin Types',
|
||||
'group ' . $group_id . ' description', $group['description']);
|
||||
}
|
||||
}
|
||||
|
||||
// Register fields
|
||||
$fields = wpcf_admin_fields_get_fields();
|
||||
foreach ($fields as $field_id => $field) {
|
||||
wpcf_translate_register_string('plugin Types',
|
||||
'field ' . $field_id . ' name', $field['name']);
|
||||
if (isset($field['description'])) {
|
||||
wpcf_translate_register_string('plugin Types',
|
||||
'field ' . $field_id . ' description', $field['description']);
|
||||
}
|
||||
|
||||
// For radios or select
|
||||
if (!empty($field['data']['options'])) {
|
||||
foreach ($field['data']['options'] as $name => $option) {
|
||||
if ($name == 'default') {
|
||||
continue;
|
||||
}
|
||||
if (isset($option['title'])) {
|
||||
wpcf_translate_register_string('plugin Types',
|
||||
'field ' . $field_id . ' option ' . $name . ' title',
|
||||
$option['title']);
|
||||
}
|
||||
if (isset($option['value'])) {
|
||||
wpcf_translate_register_string('plugin Types',
|
||||
'field ' . $field_id . ' option ' . $name . ' value',
|
||||
$option['value']);
|
||||
}
|
||||
if (isset($option['display_value'])) {
|
||||
wpcf_translate_register_string('plugin Types',
|
||||
'field ' . $field_id . ' option ' . $name . ' display value',
|
||||
$option['display_value']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($field['type'] == 'checkbox' && (isset($field['set_value']) && $field['set_value'] != '1')) {
|
||||
// we need to translate the check box value to store
|
||||
wpcf_translate_register_string('plugin Types',
|
||||
'field ' . $field_id . ' checkbox value',
|
||||
$field['set_value']);
|
||||
}
|
||||
|
||||
if ($field['type'] == 'checkbox' && !empty($field['display_value_selected'])) {
|
||||
// we need to translate the check box value to store
|
||||
wpcf_translate_register_string('plugin Types',
|
||||
'field ' . $field_id . ' checkbox value selected',
|
||||
$field['display_value_selected']);
|
||||
}
|
||||
|
||||
if ($field['type'] == 'checkbox' && !empty($field['display_value_not_selected'])) {
|
||||
// we need to translate the check box value to store
|
||||
wpcf_translate_register_string('plugin Types',
|
||||
'field ' . $field_id . ' checkbox value not selected',
|
||||
$field['display_value_not_selected']);
|
||||
}
|
||||
|
||||
// Validation message
|
||||
if (!empty($field['data']['validate'])) {
|
||||
foreach ($field['data']['validate'] as $method => $validation) {
|
||||
if (!empty($validation['message'])) {
|
||||
// Skip if it's same as default
|
||||
$default_message = wpcf_admin_validation_messages($method);
|
||||
if ($validation['message'] != $default_message) {
|
||||
wpcf_translate_register_string('plugin Types',
|
||||
'field ' . $field_id . ' validation message ' . $method,
|
||||
$validation['message']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Register types
|
||||
$custom_types = get_option('wpcf-custom-types', array());
|
||||
foreach ($custom_types as $post_type => $data) {
|
||||
wpcf_custom_types_register_translation($post_type, $data);
|
||||
}
|
||||
|
||||
// Register taxonomies
|
||||
$custom_taxonomies = get_option('wpcf-custom-taxonomies', array());
|
||||
foreach ($custom_taxonomies as $taxonomy => $data) {
|
||||
wpcf_custom_taxonimies_register_translation($taxonomy, $data);
|
||||
}
|
||||
}
|
||||
@ -1,918 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Returns HTML formatted output for elements and handles form submission.
|
||||
*
|
||||
* @version 1.0
|
||||
*/
|
||||
class Enlimbo_Forms_Wpcf
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $_id;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_errors = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_elements = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_count = array();
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $css_class = 'wpcf-form';
|
||||
|
||||
/**
|
||||
* Auto handler
|
||||
*
|
||||
* Renders.
|
||||
*
|
||||
* @param array $element
|
||||
* @return HTML formatted output
|
||||
*/
|
||||
public function autoHandle($id, $form)
|
||||
{
|
||||
// Auto-add wpnonce field
|
||||
$form['_wpnonce'] = array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => wp_nonce_field($id, '_wpnonce_wpcf', true, false)
|
||||
);
|
||||
|
||||
$this->_id = $id;
|
||||
$this->_elements = $form;
|
||||
|
||||
do_action('wpcf_form_autohandle', $id, $form, $this);
|
||||
do_action('wpcf_form_autohandle_' . $id, $form, $this);
|
||||
|
||||
// get submitted data
|
||||
if ($this->isSubmitted()) {
|
||||
|
||||
do_action('wpcf_form_autohandle_submit', $id, $form, $this);
|
||||
do_action('wpcf_form_autohandle_submit_' . $id, $form, $this);
|
||||
|
||||
// check if errors (validation)
|
||||
$this->validate($this->_elements);
|
||||
|
||||
do_action('wpcf_form_autohandle_validate', $id, $form, $this);
|
||||
do_action('wpcf_form_autohandle_validate_' . $id, $form, $this);
|
||||
|
||||
// callback
|
||||
if (empty($this->_errors)) {
|
||||
|
||||
if (isset($form['#form']['callback'])) {
|
||||
if (is_array($form['#form']['callback'])) {
|
||||
foreach ($form['#form']['callback'] as $callback) {
|
||||
if (is_callable($callback)) {
|
||||
call_user_func($callback, $this);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (is_callable($form['#form']['callback'])) {
|
||||
call_user_func($form['#form']['callback'], $this);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Maybe triggered by callback function
|
||||
if (empty($this->_errors)) {
|
||||
// redirect
|
||||
do_action('wpcf_form_autohandle_redirection', $id, $form,
|
||||
$this);
|
||||
do_action('wpcf_form_autohandle_redirection_' . $id, $form,
|
||||
$this);
|
||||
if (!isset($form['#form']['redirection'])) {
|
||||
header('Location: ' . $_SERVER['REQUEST_URI']);
|
||||
} else if ($form['#form']['redirection'] != false) {
|
||||
header('Location: ' . $form['#form']['redirection']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if form is submitted.
|
||||
*
|
||||
* @param type $id
|
||||
* @return type
|
||||
*/
|
||||
public function isSubmitted($id = '')
|
||||
{
|
||||
if (empty($id)) {
|
||||
$id = $this->_id;
|
||||
}
|
||||
return (isset($_REQUEST['_wpnonce_wpcf'])
|
||||
&& wp_verify_nonce($_REQUEST['_wpnonce_wpcf'], $id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loops over elements and validates them.
|
||||
*
|
||||
* @param type $elements
|
||||
*/
|
||||
public function validate(&$elements)
|
||||
{
|
||||
require_once WPCF_EMBEDDED_ABSPATH . '/classes/validate.php';
|
||||
foreach ($elements as $key => &$element) {
|
||||
if (!isset($element['#type'])
|
||||
|| !$this->_isValidType($element['#type'])) {
|
||||
continue;
|
||||
}
|
||||
if ($element['#type'] != 'fieldset') {
|
||||
if (isset($element['#name'])
|
||||
&& !in_array($element['#type'], array('submit', 'reset'))) {
|
||||
// Set submitted data
|
||||
if (!in_array($element['#type'], array('checkboxes'))
|
||||
&& empty($element['#forced_value'])) {
|
||||
$element['#value'] = $this->getSubmittedData($element);
|
||||
} else if (!empty($element['#options'])
|
||||
&& empty($element['#forced_value'])) {
|
||||
foreach ($element['#options'] as $option_key => $option) {
|
||||
$option['#type'] = 'checkbox';
|
||||
$element['#options'][$option_key]['#value'] = $this->getSubmittedData($option);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Validate
|
||||
if (isset($element['#validate'])) {
|
||||
$this->validateElement($element);
|
||||
}
|
||||
} else if (isset($element['#type'])
|
||||
&& $element['#type'] == 'fieldset') {
|
||||
$this->validate($element);
|
||||
} else if (is_array($element)) {
|
||||
$this->validate($element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates element.
|
||||
*
|
||||
* @param type $element
|
||||
*/
|
||||
public function validateElement(&$element)
|
||||
{
|
||||
$check = Wpcf_Validate::check($element['#validate'], $element['#value']);
|
||||
if (isset($check['error'])) {
|
||||
$this->_errors = true;
|
||||
$element['#error'] = $check['message'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there are errors.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function isError()
|
||||
{
|
||||
return $this->_errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets errors to true.
|
||||
*/
|
||||
public function triggerError()
|
||||
{
|
||||
$this->_errors = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders form.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function renderForm()
|
||||
{
|
||||
// loop over elements and render them
|
||||
return $this->renderElements($this->_elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts element types.
|
||||
*
|
||||
* @param type $type
|
||||
* @return type
|
||||
*/
|
||||
private function _count($type) {
|
||||
if (!isset($this->_count[$type])) {
|
||||
$this->_count[$type] = 0;
|
||||
}
|
||||
$this->_count[$type] += 1;
|
||||
return $this->_count[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if element is of valid type
|
||||
*
|
||||
* @param string $type
|
||||
* @return boolean
|
||||
*/
|
||||
private function _isValidType($type)
|
||||
{
|
||||
return in_array($type,
|
||||
array('select', 'checkboxes', 'checkbox', 'radios',
|
||||
'radio', 'textfield', 'textarea', 'file', 'submit', 'reset',
|
||||
'hidden', 'fieldset', 'markup', 'button'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders elements.
|
||||
*
|
||||
* @param type $elements
|
||||
* @return type
|
||||
*/
|
||||
public function renderElements($elements)
|
||||
{
|
||||
$output = '';
|
||||
foreach ($elements as $key => $element) {
|
||||
if (!isset($element['#type'])
|
||||
|| !$this->_isValidType($element['#type'])) {
|
||||
continue;
|
||||
}
|
||||
if ($element['#type'] != 'fieldset') {
|
||||
$output .= $this->renderElement($element);
|
||||
} else if (isset($element['#type'])
|
||||
&& $element['#type'] == 'fieldset') {
|
||||
$buffer = $this->renderElements($element);
|
||||
$output .= $this->fieldset($element, 'wrap', $buffer);
|
||||
} else if (is_array($element)) {
|
||||
$output .= $this->renderElements($element);
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders element.
|
||||
*
|
||||
* Depending on element type, it calls class methods.
|
||||
*
|
||||
* @param array $element
|
||||
* @return HTML formatted output
|
||||
*/
|
||||
public function renderElement($element)
|
||||
{
|
||||
$method = $element['#type'];
|
||||
if (!isset($element['#name']) && $element['#type'] != 'markup') {
|
||||
if (!isset($element['#attributes']['name'])) {
|
||||
return '#name or #attributes[\'name\'] required!';
|
||||
} else {
|
||||
$element['#name'] = $element['#attributes']['name'];
|
||||
}
|
||||
}
|
||||
if (is_callable(array($this, $method))) {
|
||||
if (!isset($element['#id'])) {
|
||||
if (isset($element['#attributes']['id'])) {
|
||||
$element['#id'] = $element['#attributes']['id'];
|
||||
} else {
|
||||
$element['#id'] = $element['#type'] . '-'
|
||||
. $this->_count($element['#type']);
|
||||
}
|
||||
}
|
||||
if (isset($this->_errors[$element['#id']])) {
|
||||
$element['#error'] = $this->_errors[$element['#id']];
|
||||
}
|
||||
// Add JS validation
|
||||
if (!empty($element['#validate'])) {
|
||||
wpcf_form_add_js_validation($element);
|
||||
}
|
||||
return $this->{$method}($element);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets other element attributes.
|
||||
*
|
||||
* @param array $element
|
||||
* @return string
|
||||
*/
|
||||
private function _setElementAttributes($element)
|
||||
{
|
||||
$attributes = '';
|
||||
$error_class = isset($element['#error']) ? ' ' . $this->css_class . '-error ' . $this->css_class . '-' . $element['#type'] . '-error ' . ' form-' . $element['#type'] . '-error ' . $element['#type'] . '-error form-error ' : '';
|
||||
$class = $this->css_class . '-' . $element['#type']
|
||||
. ' form-' . $element['#type'] . ' ' . $element['#type'];
|
||||
if (isset($element['#attributes'])) {
|
||||
foreach ($element['#attributes'] as $attribute => $value) {
|
||||
// Prevent undesired elements
|
||||
if (in_array($attribute, array('id', 'name'))) {
|
||||
continue;
|
||||
}
|
||||
// Don't set disabled for checkbox
|
||||
if ($attribute == 'disabled' && $element['#type'] == 'checkbox') {
|
||||
continue;
|
||||
}
|
||||
// Append class values
|
||||
if ($attribute == 'class') {
|
||||
$value = $value . ' ' . $class . $error_class;
|
||||
}
|
||||
// Set return string
|
||||
$attributes .= ' ' . $attribute . '="' . $value . '"';
|
||||
}
|
||||
}
|
||||
if (!isset($element['#attributes']['class'])) {
|
||||
$attributes .= ' class="' . $class . $error_class . '"';
|
||||
}
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets render elements.
|
||||
*
|
||||
* @param array $element
|
||||
*/
|
||||
private function _setRender($element)
|
||||
{
|
||||
if (!isset($element['#id'])) {
|
||||
if (isset($element['#attributes']['id'])) {
|
||||
$element['#id'] = $element['#attributes']['id'];
|
||||
} else {
|
||||
$element['#id'] = 'form-' . mt_rand();
|
||||
}
|
||||
}
|
||||
$element['_attributes_string'] = $this->_setElementAttributes($element);
|
||||
$element['_render'] = array();
|
||||
$element['_render']['prefix'] = isset($element['#prefix']) ? $element['#prefix'] . "\r\n" : '';
|
||||
$element['_render']['suffix'] = isset($element['#suffix']) ? $element['#suffix'] . "\r\n" : '';
|
||||
$element['_render']['before'] = isset($element['#before']) ? $element['#before'] . "\r\n" : '';
|
||||
$element['_render']['after'] = isset($element['#after']) ? $element['#after'] . "\r\n" : '';
|
||||
$element['_render']['label'] = isset($element['#title']) ? '<label class="'
|
||||
. $this->css_class . '-label ' . $this->css_class . '-'
|
||||
. $element['#type'] . '-label" for="' . $element['#id'] . '">'
|
||||
. stripslashes($element['#title'])
|
||||
. '</label>' . "\r\n" : '';
|
||||
$element['_render']['title'] = $this->_setElementTitle($element);
|
||||
$element['_render']['description'] = isset($element['#description']) ? $this->_setElementDescription($element) : '';
|
||||
$element['_render']['error'] = $this->renderError($element) . "\r\n";
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies pattern to output.
|
||||
*
|
||||
* Pass element property #pattern to get custom renedered element.
|
||||
*
|
||||
* @param array $pattern
|
||||
* Accepts: <prefix><suffix><label><title><desription><error>
|
||||
* @param array $element
|
||||
*/
|
||||
private function _pattern($pattern, $element)
|
||||
{
|
||||
$pattern = strtolower($pattern);
|
||||
foreach ($element['_render'] as $key => $value) {
|
||||
$pattern = str_replace('<' . strtolower($key) . '>', $value,
|
||||
$pattern);
|
||||
}
|
||||
return $pattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapps element in <div></div>.
|
||||
*
|
||||
* @param arrat $element
|
||||
* @param string $output
|
||||
* @return string
|
||||
*/
|
||||
private function _wrapElement($element, $output)
|
||||
{
|
||||
if (empty($element['#inline'])) {
|
||||
$wrapped = '<div id="' . $element['#id'] . '-wrapper"'
|
||||
. ' class="form-item form-item-' . $element['#type'] . ' '
|
||||
. $this->css_class . '-item '
|
||||
. $this->css_class . '-item-' . $element['#type']
|
||||
. '">' . $output . '</div>';
|
||||
return $wrapped;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML formatted output for element's title.
|
||||
*
|
||||
* @param string $element
|
||||
* @return string
|
||||
*/
|
||||
private function _setElementTitle($element)
|
||||
{
|
||||
$output = '';
|
||||
if (isset($element['#title'])) {
|
||||
$output .= '<div class="title '
|
||||
. $this->css_class . '-title '
|
||||
. $this->css_class . '-title-' . $element['#type'] . ' '
|
||||
. 'title-' . $element['#type'] . '">'
|
||||
. stripslashes($element['#title'])
|
||||
. "</div>\r\n";
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML formatted output for element's description.
|
||||
*
|
||||
* @param array $element
|
||||
* @return string
|
||||
*/
|
||||
private function _setElementDescription($element)
|
||||
{
|
||||
$element['#description'] = stripslashes($element['#description']);
|
||||
$output = "\r\n"
|
||||
. '<div class="description '
|
||||
. $this->css_class . '-description '
|
||||
. $this->css_class . '-description-' . $element['#type'] . ' '
|
||||
. 'description-' . $element['#type'] . '">'
|
||||
. $element['#description'] . "</div>\r\n";
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML formatted element's error message.
|
||||
*
|
||||
* Pass #supress_errors in #form element to avoid error rendering.
|
||||
*
|
||||
* @param array $element
|
||||
* @return string
|
||||
*/
|
||||
public function renderError($element)
|
||||
{
|
||||
if (!isset($element['#error'])) {
|
||||
return '';
|
||||
}
|
||||
$output = '<div class="form-error '
|
||||
. $this->css_class . '-error '
|
||||
. $this->css_class . '-form-error '
|
||||
. $this->css_class . '-' . $element['#type'] . '-error '
|
||||
. $element['#type'] . '-error form-error-label'
|
||||
. '">' . $element['#error'] . '</div>'
|
||||
. "\r\n";
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML formatted output for fieldset.
|
||||
*
|
||||
* @param array $element
|
||||
* @param string $action open|close|wrap
|
||||
* @param string $wrap_content HTML formatted output of child elements
|
||||
* @return string
|
||||
*/
|
||||
public function fieldset($element, $action = 'open', $wrap_content = '')
|
||||
{
|
||||
$collapsible_open = '<div class="fieldset-wrapper">';
|
||||
$collapsible_close = '</div>';
|
||||
$legend_class = '';
|
||||
if (!isset($element['#id'])) {
|
||||
$element['#id'] = 'fieldset-' . $this->_count('fieldset');
|
||||
}
|
||||
if (!isset($element['_attributes_string'])) {
|
||||
$element['_attributes_string'] = $this->_setElementAttributes($element);
|
||||
}
|
||||
if ((isset($element['#collapsible']) && $element['#collapsible'])
|
||||
|| (isset($element['#collapsed']) && $element['#collapsed'])) {
|
||||
$collapsible_open = '<div class="collapsible fieldset-wrapper">';
|
||||
$collapsible_close = '</div>';
|
||||
$legend_class = ' class="legend-expanded"';
|
||||
}
|
||||
if (isset($element['#collapsed']) && $element['#collapsed']) {
|
||||
$collapsible_open = str_replace('class="', 'class="collapsed ',
|
||||
$collapsible_open);
|
||||
$legend_class = ' class="legend-collapsed"';
|
||||
}
|
||||
$output = '';
|
||||
switch ($action) {
|
||||
case 'close':
|
||||
$output .= $collapsible_close . "</fieldset>\r\n";
|
||||
$output .= isset($element['#suffix']) ? $element['#suffix']
|
||||
. "\r\n" : '';
|
||||
$output .= "\n\r";
|
||||
break;
|
||||
|
||||
case 'open':
|
||||
$output .= $collapsible_open;
|
||||
$output .= isset($element['#prefix']) ? $element['#prefix']
|
||||
. "\r\n" : '';
|
||||
$output .= '<fieldset' . $element['_attributes_string']
|
||||
. ' id="' . $element['#id'] . '">' . "\r\n";
|
||||
$output .= isset($element['#title']) ? '<legend'
|
||||
. $legend_class . '>'
|
||||
. stripslashes($element['#title'])
|
||||
. "</legend>\r\n" : '';
|
||||
$output .=
|
||||
isset($element['#description']) ? $this->_setElementDescription($element) : '';
|
||||
$output .= "\n\r";
|
||||
break;
|
||||
|
||||
case 'wrap':
|
||||
if (!empty($wrap_content)) {
|
||||
$output .= isset($element['#prefix']) ? $element['#prefix'] : '';
|
||||
$output .= '<fieldset' . $element['_attributes_string']
|
||||
. ' id="' . $element['#id'] . '">' . "\r\n";
|
||||
$output .= '<legend' . $legend_class . '>'
|
||||
. stripslashes($element['#title'])
|
||||
. "</legend>\r\n"
|
||||
. $collapsible_open;
|
||||
$output .= isset($element['#description']) ? $this->_setElementDescription($element) : '';
|
||||
$output .= $wrap_content . $collapsible_close
|
||||
. "</fieldset>\r\n";
|
||||
$output .=
|
||||
isset($element['#suffix']) ? $element['#suffix'] : '';
|
||||
$output .= "\n\r";
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML formatted output for checkbox element.
|
||||
*
|
||||
* @param array $element
|
||||
* @return string
|
||||
*/
|
||||
public function checkbox($element)
|
||||
{
|
||||
$element['#type'] = 'checkbox';
|
||||
$element = $this->_setRender($element);
|
||||
$element['_render']['element'] = '<input type="checkbox" id="'
|
||||
. $element['#id'] . '" name="'
|
||||
. $element['#name'] . '" value="';
|
||||
// Specific: if value is empty force 1 to be rendered
|
||||
$element['_render']['element'] .=
|
||||
!empty($element['#value']) ? htmlspecialchars($element['#value']) : 1;
|
||||
$element['_render']['element'] .= '"' . $element['_attributes_string'];
|
||||
$element['_render']['element'] .= ((!$this->isSubmitted()
|
||||
&& !empty($element['#default_value']))
|
||||
|| ($this->isSubmitted()
|
||||
&& !empty($element['#value']))) ? ' checked="checked"' : '';
|
||||
if (!empty($element['#attributes']['disabled']) || !empty($element['#disable'])) {
|
||||
$element['_render']['element'] .= ' onclick="javascript:return false; if(this.checked == 1){this.checked=1; return true;}else{this.checked=0; return false;}"';
|
||||
}
|
||||
$element['_render']['element'] .= ' />';
|
||||
$pattern = isset($element['#pattern']) ? $element['#pattern'] : '<BEFORE><PREFIX><ELEMENT> <LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>';
|
||||
$output = $this->_pattern($pattern, $element);
|
||||
$output = $this->_wrapElement($element, $output);
|
||||
return $output . "\r\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML formatted output for checkboxes element.
|
||||
*
|
||||
* Renders more than one checkboxes provided as elements in '#options'
|
||||
* array element.
|
||||
*
|
||||
* @param array $element
|
||||
* @return string
|
||||
*/
|
||||
public function checkboxes($element)
|
||||
{
|
||||
$element['#type'] = 'checkboxes';
|
||||
$element = $this->_setRender($element);
|
||||
$clone = $element;
|
||||
$clone['#type'] = 'checkbox';
|
||||
$element['_render']['element'] = '';
|
||||
foreach ($element['#options'] as $ID => $value) {
|
||||
if (!is_array($value)) {
|
||||
$value = array('#title' => $ID, '#value' => $value, '#name' => $element['#name'] . '[]');
|
||||
}
|
||||
$element['_render']['element'] .= $this->checkbox($value);
|
||||
}
|
||||
$pattern = isset($element['#pattern']) ? $element['#pattern'] : '<BEFORE><PREFIX><TITLE><DESCRIPTION><ELEMENT><SUFFIX><AFTER>';
|
||||
$output = $this->_pattern($pattern, $element);
|
||||
$output = $this->_wrapElement($element, $output);
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML formatted output for radio element.
|
||||
*
|
||||
* @param array $element
|
||||
* @return string
|
||||
*/
|
||||
public function radio($element)
|
||||
{
|
||||
$element['#type'] = 'radio';
|
||||
$element = $this->_setRender($element);
|
||||
$element['_render']['element'] = '<input type="radio" id="'
|
||||
. $element['#id'] . '" name="'
|
||||
. $element['#name'] . '" value="';
|
||||
$element['_render']['element'] .= isset($element['#value']) ? htmlspecialchars($element['#value']) : $this->_count['radio'];
|
||||
$element['_render']['element'] .= '"';
|
||||
$element['_render']['element'] .= $element['_attributes_string'];
|
||||
$element['_render']['element'] .= ( isset($element['#value'])
|
||||
&& $element['#value'] === $element['#default_value']) ? ' checked="checked"' : '';
|
||||
if (isset($element['#disable']) && $element['#disable']) {
|
||||
$element['_render']['element'] .= ' disabled="disabled"';
|
||||
}
|
||||
$element['_render']['element'] .= ' />';
|
||||
$pattern = isset($element['#pattern']) ? $element['#pattern'] : '<BEFORE><PREFIX><ELEMENT> <LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>';
|
||||
$output = $this->_pattern($pattern, $element);
|
||||
$output = $this->_wrapElement($element, $output);
|
||||
return $output . "\r\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML formatted output for radios elements.
|
||||
*
|
||||
* Radios are provided via #options array.
|
||||
* Requires #name value.
|
||||
*
|
||||
* @param array $element
|
||||
* @return string
|
||||
*/
|
||||
public function radios($element)
|
||||
{
|
||||
if (!isset($element['#name']) || empty($element['#name'])) {
|
||||
return FALSE;
|
||||
}
|
||||
$element['#type'] = 'radios';
|
||||
$element = $this->_setRender($element);
|
||||
$element['_render']['element'] = '';
|
||||
foreach ($element['#options'] as $ID => $value) {
|
||||
$this->_count('radio');
|
||||
if (!is_array($value)) {
|
||||
$value = array('#title' => $ID, '#value' => $value);
|
||||
$value['#inline'] = true;
|
||||
$value['#after'] = '<br />';
|
||||
}
|
||||
$value['#name'] = $element['#name'];
|
||||
$value['#default_value'] = isset($element['#default_value']) ? $element['#default_value'] : $value['#value'];
|
||||
$value['#disable'] = isset($element['#disable']) ? $element['#disable'] : false;
|
||||
$element['_render']['element'] .= $this->radio($value);
|
||||
}
|
||||
$pattern = isset($element['#pattern']) ? $element['#pattern'] : '<BEFORE><PREFIX><TITLE><DESCRIPTION><ELEMENT><SUFFIX><AFTER>';
|
||||
$output = $this->_pattern($pattern, $element);
|
||||
$output = $this->_wrapElement($element, $output);
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML formatted output for select element.
|
||||
*
|
||||
* @param array $element
|
||||
* @return string
|
||||
*/
|
||||
public function select($element)
|
||||
{
|
||||
$element['#type'] = 'select';
|
||||
$element = $this->_setRender($element);
|
||||
$element['_render']['element'] = '<select id="' . $element['#id']
|
||||
. '" name="' . $element['#name'] . '"'
|
||||
. $element['_attributes_string'] . ">\r\n";
|
||||
$count = 1;
|
||||
foreach ($element['#options'] as $id => $value) {
|
||||
if (!is_array($value)) {
|
||||
$value = array('#title' => $id, '#value' => $value);
|
||||
}
|
||||
if (!isset($value['#value'])) {
|
||||
$value['#value'] = $this->_count['select'] . '-' . $count;
|
||||
$count += 1;
|
||||
}
|
||||
$value['#type'] = 'option';
|
||||
$element['_render']['element'] .= '<option value="'
|
||||
. htmlspecialchars($value['#value']) . '"';
|
||||
$element['_render']['element'] .= ( $element['#default_value']
|
||||
== $value['#value']) ? ' selected="selected"' : '';
|
||||
$element['_render']['element'] .= $this->_setElementAttributes($value);
|
||||
$element['_render']['element'] .= '>';
|
||||
$element['_render']['element'] .= isset($value['#title']) ? $value['#title'] : $value['#value'];
|
||||
$element['_render']['element'] .= "</option>\r\n";
|
||||
}
|
||||
$element['_render']['element'] .= "</select>\r\n";
|
||||
$pattern = isset($element['#pattern']) ? $element['#pattern'] : '<BEFORE><LABEL><DESCRIPTION><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER>';
|
||||
$output = $this->_pattern($pattern, $element);
|
||||
$output = $this->_wrapElement($element, $output);
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML formatted output for textfield element.
|
||||
*
|
||||
* @param array $element
|
||||
* @return string
|
||||
*/
|
||||
public function textfield($element)
|
||||
{
|
||||
$element['#type'] = 'textfield';
|
||||
$element = $this->_setRender($element);
|
||||
$element['_render']['element'] = '<input type="text" id="'
|
||||
. $element['#id'] . '" name="' . $element['#name'] . '" value="';
|
||||
$element['_render']['element'] .= isset($element['#value']) ? htmlspecialchars(stripslashes($element['#value'])) : '';
|
||||
$element['_render']['element'] .= '"' . $element['_attributes_string'];
|
||||
if (isset($element['#disable']) && $element['#disable']) {
|
||||
$element['_render']['element'] .= ' disabled="disabled"';
|
||||
}
|
||||
$element['_render']['element'] .= ' />';
|
||||
$pattern = isset($element['#pattern']) ? $element['#pattern'] : '<BEFORE><LABEL><ERROR><PREFIX><ELEMENT><SUFFIX><DESCRIPTION><AFTER>';
|
||||
$output = $this->_pattern($pattern, $element);
|
||||
$output = $this->_wrapElement($element, $output);
|
||||
return $output . "\r\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML formatted output for textfield element.
|
||||
*
|
||||
* @param array $element
|
||||
* @return string
|
||||
*/
|
||||
public function password($element)
|
||||
{
|
||||
$element['#type'] = 'password';
|
||||
$element = $this->_setRender($element);
|
||||
$element['_render']['element'] = '<input type="password" id="'
|
||||
. $element['#id'] . '" name="' . $element['#name'] . '" value="';
|
||||
$element['_render']['element'] .= isset($element['#value']) ? $element['#value'] : '';
|
||||
$element['_render']['element'] .= '"' . $element['_attributes_string'];
|
||||
if (isset($element['#disable']) && $element['#disable']) {
|
||||
$element['_render']['element'] .= ' disabled="disabled"';
|
||||
}
|
||||
$element['_render']['element'] .= ' />';
|
||||
$pattern = isset($element['#pattern']) ? $element['#pattern'] : '<BEFORE><LABEL><ERROR><PREFIX><ELEMENT><SUFFIX><DESCRIPTION><AFTER>';
|
||||
$output = $this->_pattern($pattern, $element);
|
||||
$output = $this->_wrapElement($element, $output);
|
||||
return $output . "\r\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML formatted output for textarea element.
|
||||
*
|
||||
* @param array $element
|
||||
* @return string
|
||||
*/
|
||||
public function textarea($element)
|
||||
{
|
||||
$element['#type'] = 'textarea';
|
||||
if (!isset($element['#attributes']['rows'])) {
|
||||
$element['#attributes']['rows'] = 5;
|
||||
}
|
||||
if (!isset($element['#attributes']['cols'])) {
|
||||
$element['#attributes']['cols'] = 1;
|
||||
}
|
||||
$element = $this->_setRender($element);
|
||||
$element['_render']['element'] = '<textarea id="' . $element['#id']
|
||||
. '" name="' . $element['#name'] . '"'
|
||||
. $element['_attributes_string'] . '>';
|
||||
$element['_render']['element'] .= isset($element['#value']) ? htmlspecialchars(stripslashes($element['#value'])) : '';
|
||||
$element['_render']['element'] .= '</textarea>' . "\r\n";
|
||||
$pattern = isset($element['#pattern']) ? $element['#pattern'] : '<BEFORE><LABEL><DESCRIPTION><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER>';
|
||||
$output = $this->_pattern($pattern, $element);
|
||||
$output = $this->_wrapElement($element, $output);
|
||||
return $output . "\r\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML formatted output for file upload element.
|
||||
*
|
||||
* @param array $element
|
||||
* @return string
|
||||
*/
|
||||
public function file($element)
|
||||
{
|
||||
$element['#type'] = 'file';
|
||||
$element = $this->_setRender($element);
|
||||
$element['_render']['element'] = '<input type="file" id="'
|
||||
. $element['#id'] . '" name="' . $element['#name'] . '"'
|
||||
. $element['_attributes_string'];
|
||||
if (isset($element['#disable']) && $element['#disable']) {
|
||||
$element['_render']['element'] .= ' disabled="disabled"';
|
||||
}
|
||||
$element['_render']['element'] .= ' />';
|
||||
$pattern = isset($element['#pattern']) ? $element['#pattern'] : '<BEFORE><LABEL><ERROR><PREFIX><ELEMENT><DESCRIPTION><SUFFIX><AFTER>';
|
||||
$output = $this->_pattern($pattern, $element);
|
||||
$output = $this->_wrapElement($element, $output);
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML formatted output for markup element.
|
||||
*
|
||||
* @param array $element
|
||||
* @return string
|
||||
*/
|
||||
public function markup($element)
|
||||
{
|
||||
return $element['#markup'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML formatted output for hidden element.
|
||||
*
|
||||
* @param array $element
|
||||
* @return string
|
||||
*/
|
||||
public function hidden($element)
|
||||
{
|
||||
$element['#type'] = 'hidden';
|
||||
$output = '<input type="hidden" id="' . $element['#id'] . '" name="'
|
||||
. $element['#name'] . '" value="';
|
||||
$output .= isset($element['#value']) ? $element['#value'] : 1;
|
||||
$output .= '" />';
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML formatted output for reset button element.
|
||||
*
|
||||
* @param array $element
|
||||
* @return string
|
||||
*/
|
||||
public function reset($element)
|
||||
{
|
||||
return $this->submit($element, 'reset', 'Reset');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML formatted output for button element.
|
||||
*
|
||||
* @param array $element
|
||||
* @return string
|
||||
*/
|
||||
public function button($element)
|
||||
{
|
||||
return $this->submit($element, 'button', 'Button');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML formatted output for radio element.
|
||||
*
|
||||
* Used by reset and button.
|
||||
*
|
||||
* @param array $element
|
||||
* @param string $type
|
||||
* @param string $title
|
||||
* @return string
|
||||
*/
|
||||
public function submit($element, $type = 'submit', $title = 'Submit')
|
||||
{
|
||||
$element['#type'] = $type;
|
||||
$element = $this->_setRender($element);
|
||||
$element['_render']['element'] = '<input type="' . $type . '" id="'
|
||||
. $element['#id'] . '" name="' . $element['#name'] . '" value="';
|
||||
$element['_render']['element'] .= isset($element['#value']) ? $element['#value'] : $title;
|
||||
$element['_render']['element'] .= '"' . $element['_attributes_string']
|
||||
. ' />';
|
||||
$pattern = isset($element['#pattern']) ? $element['#pattern'] : '<BEFORE><PREFIX><ELEMENT><SUFFIX><AFTER>';
|
||||
$output = $this->_pattern($pattern, $element);
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches and returns submitted data for element.
|
||||
*
|
||||
* @param type $element
|
||||
* @return type mixed
|
||||
*/
|
||||
public function getSubmittedData($element)
|
||||
{
|
||||
$name = $element['#name'];
|
||||
if (strpos($name, '[') === false) {
|
||||
if ($element['#type'] == 'file') {
|
||||
return $_FILES[$name]['tmp_name'];
|
||||
}
|
||||
return isset($_REQUEST[$name]) ? $_REQUEST[$name] : in_array($element['#type'],
|
||||
array('textfield', 'textarea')) ? '' : 0;
|
||||
}
|
||||
|
||||
$parts = explode('[', $name);
|
||||
$parts = array_map(create_function('&$a', 'return trim($a, \']\');'),
|
||||
$parts);
|
||||
if (!isset($_REQUEST[$parts[0]])) {
|
||||
return in_array($element['#type'], array('textfield', 'textarea')) ? '' : 0;
|
||||
}
|
||||
$search = $_REQUEST[$parts[0]];
|
||||
for ($index = 0; $index < count($parts); $index++) {
|
||||
$key = $parts[$index];
|
||||
// We're at the end but no data retrieved
|
||||
if (!isset($parts[$index + 1])) {
|
||||
return in_array($element['#type'],
|
||||
array('textfield', 'textarea')) ? '' : 0;
|
||||
}
|
||||
$key_next = $parts[$index + 1];
|
||||
if ($index > 0) {
|
||||
if (!isset($search[$key])) {
|
||||
return in_array($element['#type'],
|
||||
array('textfield', 'textarea')) ? '' : 0;
|
||||
} else {
|
||||
$search = $search[$key];
|
||||
}
|
||||
}
|
||||
if (is_array($search) && array_key_exists($key_next, $search)) {
|
||||
if (!is_array($search[$key_next])) {
|
||||
return $search[$key_next];
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1,422 +0,0 @@
|
||||
<?php
|
||||
require_once dirname(__FILE__) . '/validation-cakephp.php';
|
||||
|
||||
/**
|
||||
* Validation class
|
||||
*
|
||||
* @version 1.0
|
||||
*/
|
||||
class Wpcf_Validate
|
||||
{
|
||||
|
||||
/**
|
||||
* Holds generic messages.
|
||||
* @var type
|
||||
*/
|
||||
public static $messages = null;
|
||||
/**
|
||||
* Holds function names.
|
||||
* @var type
|
||||
*/
|
||||
private static $_cake_aliases = array(
|
||||
'digits' => 'numeric',
|
||||
'number' => 'numeric',
|
||||
'alphanumeric' => 'alphaNumericWhitespaces',
|
||||
'nospecialchars' => 'noSpecialChars',
|
||||
);
|
||||
/**
|
||||
* Current validation has 'required' method.
|
||||
* @var type
|
||||
*/
|
||||
private static $_is_required = false;
|
||||
|
||||
private static $_validation_object = null;
|
||||
|
||||
/**
|
||||
* Sets calls.
|
||||
*
|
||||
* @param type $args
|
||||
* @param type $value
|
||||
* @return type
|
||||
*/
|
||||
public static function check($args, $value)
|
||||
{
|
||||
// Init validation object
|
||||
if (is_null(self::$_validation_object)) {
|
||||
self::$_validation_object = new Wpcf_Cake_Validation();
|
||||
}
|
||||
|
||||
// Init messages
|
||||
if (is_null(self::$messages)) {
|
||||
self::_set_messages();
|
||||
}
|
||||
// Check if there is 'required' method
|
||||
if (array_key_exists('required', $args)) {
|
||||
self::$_is_required = true;
|
||||
}
|
||||
|
||||
// Loop over validation array
|
||||
foreach ($args as $method => $v) {
|
||||
// Use this class method
|
||||
if (is_callable(array('Wpcf_Validate', $method))) {
|
||||
$check = call_user_func_array(array('Wpcf_Validate', $method),
|
||||
array($v, $value));
|
||||
// Use CakePHP method
|
||||
} else if ((isset(self::$_cake_aliases[$method])
|
||||
&& is_callable(array('Wpcf_Cake_Validation', self::$_cake_aliases[$method])))
|
||||
|| is_callable(array('Wpcf_Cake_Validation', $method))) {
|
||||
|
||||
// Check if validation pattern is set
|
||||
if (isset($v['pattern'])) {
|
||||
$pattern = array_flip(explode('.', $v['pattern']));
|
||||
foreach ($pattern as $arg_key => $arg_value) {
|
||||
if (isset($v[$arg_key])) {
|
||||
$pattern[$arg_key] = $v[$arg_key];
|
||||
}
|
||||
}
|
||||
$pattern['check'] = $value;
|
||||
$v = $pattern;
|
||||
// Apply simple pattern (check, value)
|
||||
} else {
|
||||
unset($v['active'], $v['message']);
|
||||
$v = array($value) + $v;
|
||||
}
|
||||
|
||||
// Validate
|
||||
if (isset(self::$_cake_aliases[$method]) && is_callable(array('Wpcf_Cake_Validation', self::$_cake_aliases[$method]))) {
|
||||
// $check = @call_user_func_array(array('Wpcf_Cake_Validation', self::$_cake_aliases[$method]),
|
||||
// array_values($v));
|
||||
$check = @call_user_func_array(array(self::$_validation_object, self::$_cake_aliases[$method]),
|
||||
array_values($v));
|
||||
} else {
|
||||
// $check = @call_user_func_array(array('Wpcf_Cake_Validation', $method),
|
||||
// array_values($v));
|
||||
$check = @call_user_func_array(array(self::$_validation_object, $method),
|
||||
array_values($v));
|
||||
}
|
||||
if (!$check) {
|
||||
$check = array();
|
||||
$check['error'] = 1;
|
||||
}
|
||||
// No method available
|
||||
} else {
|
||||
return array('error' => 1, 'message' => 'No validation method');
|
||||
}
|
||||
|
||||
// Set error
|
||||
if (isset($check['error'])) {
|
||||
// Don't return error if it's empty but not required
|
||||
if ((!empty($value) && $method != 'required' && self::$_is_required)
|
||||
|| (empty($value) && $method == 'required')) {
|
||||
$check['message'] = !empty($v['message']) ? $v['message'] : self::$messages[$method];
|
||||
return $check;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if method is available.
|
||||
*
|
||||
* @param type $method
|
||||
* @return type
|
||||
*/
|
||||
public static function canValidate($method)
|
||||
{
|
||||
return (is_callable(array('Wpcf_Validate', $method))
|
||||
|| (isset(self::$_cake_aliases[$method])
|
||||
&& is_callable(array('Wpcf_Cake_Validation', self::$_cake_aliases[$method])))
|
||||
|| is_callable(array('Wpcf_Cake_Validation', $method)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if method has form data.
|
||||
*
|
||||
* @param type $method
|
||||
* @return type
|
||||
*/
|
||||
public static function hasForm($method)
|
||||
{
|
||||
return is_callable(array('Wpcf_Validate', $method . '_form'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Inits messages.
|
||||
*/
|
||||
private static function _set_messages()
|
||||
{
|
||||
// Set outside in /admin.php
|
||||
self::$messages = wpcf_admin_validation_messages();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return method invalid message.
|
||||
*
|
||||
* @param type $method
|
||||
* @return type
|
||||
*/
|
||||
public static function get_message($method)
|
||||
{
|
||||
if (is_null(self::$messages)) {
|
||||
self::_set_messages();
|
||||
}
|
||||
if (isset(self::$messages[$method])) {
|
||||
return self::$messages[$method];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks 'required'.
|
||||
*
|
||||
* @param type $args
|
||||
* @param type $value
|
||||
* @return type
|
||||
*/
|
||||
public static function required($args, $value)
|
||||
{
|
||||
if (empty($value) && $value !== 0 && $value !== '0') {
|
||||
return array(
|
||||
'error' => 1,
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns form data.
|
||||
*
|
||||
* @param type $field
|
||||
* @param type $data
|
||||
* @return array
|
||||
*/
|
||||
public static function required_form($field, $data = array())
|
||||
{
|
||||
$form = array();
|
||||
$form['required-checkbox'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => __('Required', 'wpcf'),
|
||||
'#name' => $field['#name'] . '[active]',
|
||||
'#default_value' => isset($data['active']) ? 1 : 0,
|
||||
'#inline' => true,
|
||||
'#suffix' => '<br />',
|
||||
);
|
||||
$form['required-value'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => 'true',
|
||||
'#name' => $field['#name'] . '[value]',
|
||||
);
|
||||
$form['required-message'] = self::get_custom_message($field,
|
||||
self::get_message('required'), $data);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks 'email'.
|
||||
*
|
||||
* @param type $args
|
||||
* @param type $value
|
||||
* @return type
|
||||
*/
|
||||
public static function email($args, $value)
|
||||
{
|
||||
if (!is_email($value)) {
|
||||
return array(
|
||||
'error' => 1,
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks 'rewriteslug'.
|
||||
*
|
||||
* @param type $args
|
||||
* @param type $value
|
||||
* @return type
|
||||
*/
|
||||
public static function rewriteslug($args, $value)
|
||||
{
|
||||
if (preg_match('#[^a-zA-Z0-9\/\_\-\%]#', $value) === false) {
|
||||
return array(
|
||||
'error' => 1,
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns form data.
|
||||
*
|
||||
* @param type $field
|
||||
* @param type $data
|
||||
* @return array
|
||||
*/
|
||||
public static function email_form($field, $data = array())
|
||||
{
|
||||
$form = array();
|
||||
$form['email-checkbox'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => __('Email', 'wpcf'),
|
||||
'#name' => $field['#name'] . '[active]',
|
||||
'#default_value' => isset($data['active']) ? 1 : 0,
|
||||
'#inline' => true,
|
||||
'#suffix' => '<br />',
|
||||
);
|
||||
|
||||
$form['email-message'] = self::get_custom_message($field,
|
||||
self::get_message('email'), $data);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns form data.
|
||||
*
|
||||
* @param type $field
|
||||
* @param type $data
|
||||
* @return array
|
||||
*/
|
||||
public static function url_form($field, $data = array())
|
||||
{
|
||||
$form = array();
|
||||
$form['url-checkbox'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => 'URL',
|
||||
'#name' => $field['#name'] . '[active]',
|
||||
'#default_value' => isset($data['active']) ? 1 : 0,
|
||||
'#inline' => true,
|
||||
'#suffix' => '<br />',
|
||||
);
|
||||
|
||||
$form['url-message'] = self::get_custom_message($field,
|
||||
self::get_message('url'), $data);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns form data.
|
||||
*
|
||||
* @param type $field
|
||||
* @param type $data
|
||||
* @return array
|
||||
*/
|
||||
public static function date_form($field, $data = array())
|
||||
{
|
||||
$form = array();
|
||||
$form['date-checkbox'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => __('Date', 'wpcf'),
|
||||
'#name' => $field['#name'] . '[active]',
|
||||
'#default_value' => isset($data['active']) ? 1 : 0,
|
||||
'#inline' => true,
|
||||
'#suffix' => '<br />',
|
||||
);
|
||||
$form['date-format'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => 'mdy',
|
||||
'#name' => $field['#name'] . '[format]',
|
||||
);
|
||||
$form['date-pattern'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => 'check.format',
|
||||
'#name' => $field['#name'] . '[pattern]',
|
||||
);
|
||||
$form['url-message'] = self::get_custom_message($field,
|
||||
self::get_message('date'), $data);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns form data.
|
||||
*
|
||||
* @param type $field
|
||||
* @param type $data
|
||||
* @return array
|
||||
*/
|
||||
public static function digits_form($field, $data = array())
|
||||
{
|
||||
$form = array();
|
||||
$attributes = array();
|
||||
$default_value = isset($data['active']) ? 1 : 0;
|
||||
$form['digits-checkbox'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => __('Digits', 'wpcf'),
|
||||
'#name' => $field['#name'] . '[active]',
|
||||
'#default_value' => $default_value,
|
||||
'#inline' => true,
|
||||
'#suffix' => '<br />',
|
||||
'#attributes' => $attributes,
|
||||
);
|
||||
$form['digits-checkbox'] = self::setForced($form['digits-checkbox'], $field, $data);
|
||||
|
||||
$form['digits-message'] = self::get_custom_message($field,
|
||||
self::get_message('digits'), $data);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns form data.
|
||||
*
|
||||
* @param type $field
|
||||
* @param type $data
|
||||
* @return array
|
||||
*/
|
||||
public static function number_form($field, $data = array())
|
||||
{
|
||||
$form = array();
|
||||
$attributes = array();
|
||||
$default_value = isset($data['active']) ? 1 : 0;
|
||||
$form['number-checkbox'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => __('Numeric', 'wpcf'),
|
||||
'#name' => $field['#name'] . '[active]',
|
||||
'#default_value' => $default_value,
|
||||
'#inline' => true,
|
||||
'#suffix' => '<br />',
|
||||
'#attributes' => $attributes,
|
||||
);
|
||||
$form['number-checkbox'] = self::setForced($form['number-checkbox'], $field, $data);
|
||||
|
||||
$form['number-message'] = self::get_custom_message($field,
|
||||
self::get_message('number'), $data);
|
||||
return $form;
|
||||
}
|
||||
|
||||
public static function setForced($element, $field, $data = array())
|
||||
{
|
||||
$attributes = array();
|
||||
$default_value = isset($data['active']) ? 1 : 0;
|
||||
if (!empty($data['method_data']['forced'])) {
|
||||
if (!isset($element['#attributes'])) {
|
||||
$element['#attributes'] = array();
|
||||
}
|
||||
$element['#attributes']['readonly'] = 'readonly';
|
||||
$element['#attributes']['onclick'] = 'jQuery(this).attr(\'checked\', \'checked\');';
|
||||
$element['#default_value'] = 1;
|
||||
}
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'custom message' field.
|
||||
*
|
||||
* @param type $field
|
||||
* @param type $default
|
||||
* @param type $data
|
||||
* @return type
|
||||
*/
|
||||
public static function get_custom_message($field, $default, $data)
|
||||
{
|
||||
return array(
|
||||
'#type' => 'textfield',
|
||||
// '#title' => __('Custom message', 'wpcf'),
|
||||
'#name' => $field['#name'] . '[message]',
|
||||
'#value' => !empty($data['message']) ? $data['message'] : $default,
|
||||
'#inline' => true,
|
||||
// '#suffix' => '<br /><br />',
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
/** provide default implementation of [wpml-string] shortcode for when
|
||||
* wpml plugin is not active.
|
||||
*/
|
||||
|
||||
if (!isset($wpml_string_sub_active)) {
|
||||
|
||||
add_action('init', 'stub_wpml_add_shortcode', 100);
|
||||
|
||||
$wpml_string_sub_active = true;
|
||||
|
||||
function stub_wpml_add_shortcode() {
|
||||
global $WPML_String_Translation;
|
||||
|
||||
if (!isset($WPML_String_Translation)) {
|
||||
// WPML string translation is not active
|
||||
// Add our own do nothing shortcode
|
||||
|
||||
add_shortcode('wpml-string', 'stub_wpml_string_shortcode');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function stub_wpml_string_shortcode($atts, $value) {
|
||||
// return un-processed.
|
||||
return do_shortcode($value);
|
||||
}
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!class_exists('ICL_Array2XML')) {
|
||||
|
||||
/**
|
||||
* Converts array to XML
|
||||
*/
|
||||
class ICL_Array2XML
|
||||
{
|
||||
|
||||
var $text;
|
||||
var $arrays, $keys, $node_flag, $depth, $xml_parser;
|
||||
|
||||
function array2xml($array, $root) {
|
||||
$this->depth = 1;
|
||||
$this->text = "<?xml version=\"1.0\" encoding=\""
|
||||
. get_option('blog_charset'). "\"?>\r\n<$root>\r\n";
|
||||
$this->text .= $this->array_transform($array);
|
||||
$this->text .="</$root>";
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
function array_transform($array) {
|
||||
$output = '';
|
||||
$indent = str_repeat(' ', $this->depth * 4);
|
||||
$child_key = false;
|
||||
if (isset($array['__key'])) {
|
||||
$child_key = $array['__key'];
|
||||
unset($array['__key']);
|
||||
}
|
||||
foreach ($array as $key => $value) {
|
||||
if (!is_array($value)) {
|
||||
if (empty($key) || empty($value)) {
|
||||
continue;
|
||||
}
|
||||
$key = $child_key ? $child_key : $key;
|
||||
$output .= $indent . "<$key>" . htmlspecialchars($value, ENT_QUOTES) . "</$key>\r\n";
|
||||
} else {
|
||||
$this->depth++;
|
||||
$key = $child_key ? $child_key : $key;
|
||||
$output_temp = $this->array_transform($value);
|
||||
if (!empty($output_temp)) {
|
||||
$output .= $indent . "<$key>\r\n";
|
||||
$output .= $output_temp;
|
||||
$output .= $indent . "</$key>\r\n";
|
||||
}
|
||||
$this->depth--;
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,433 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Common functions.
|
||||
*/
|
||||
define('ICL_COMMON_FUNCTIONS', true);
|
||||
/**
|
||||
* Calculates relative path for given file.
|
||||
*
|
||||
* @param type $file Absolute path to file
|
||||
* @return string Relative path
|
||||
*/
|
||||
function icl_get_file_relpath($file) {
|
||||
$is_https = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on';
|
||||
$http_protocol = $is_https ? 'https' : 'http';
|
||||
$base_root = $http_protocol . '://' . $_SERVER['HTTP_HOST'];
|
||||
$base_url = $base_root;
|
||||
$dir = rtrim(dirname($file), '\/');
|
||||
if ($dir) {
|
||||
$base_path = $dir;
|
||||
$base_url .= $base_path;
|
||||
$base_path .= '/';
|
||||
} else {
|
||||
$base_path = '/';
|
||||
}
|
||||
$relpath = $base_root
|
||||
. str_replace(
|
||||
str_replace('\\', '/', realpath($_SERVER['DOCUMENT_ROOT']))
|
||||
, '', str_replace('\\', '/', dirname($file))
|
||||
);
|
||||
return $relpath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix WP's multiarray parsing.
|
||||
*
|
||||
* @param type $arg
|
||||
* @param type $defaults
|
||||
* @return type
|
||||
*/
|
||||
function wpv_parse_args_recursive($arg, $defaults) {
|
||||
$temp = false;
|
||||
if (isset($arg[0])) {
|
||||
$temp = $arg[0];
|
||||
} else if (isset($defaults[0])) {
|
||||
$temp = $defaults[0];
|
||||
}
|
||||
$arg = wp_parse_args($arg, $defaults);
|
||||
if ($temp) {
|
||||
$arg[0] = $temp;
|
||||
}
|
||||
foreach ($defaults as $default_setting_parent => $default_setting) {
|
||||
if (!is_array($default_setting)) {
|
||||
if (!isset($arg[$default_setting_parent])) {
|
||||
$arg[$default_setting_parent] = $default_setting;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!isset($arg[$default_setting_parent])) {
|
||||
$arg[$default_setting_parent] = $defaults[$default_setting_parent];
|
||||
}
|
||||
$arg[$default_setting_parent] = wpv_parse_args_recursive($arg[$default_setting_parent], $defaults[$default_setting_parent]);
|
||||
}
|
||||
|
||||
return $arg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Condition function to evaluate and display given block based on expressions
|
||||
* 'args' => arguments for evaluation fields
|
||||
*
|
||||
* Supported actions and symbols:
|
||||
*
|
||||
* Integer and floating-point numbers
|
||||
* Math operators: +, -, *, /
|
||||
* Comparison operators: <, >, =, <=, >=, !=
|
||||
* Boolean operators: AND, OR, NOT
|
||||
* Nested expressions - several levels of brackets
|
||||
* Variables defined as shortcode parameters starting with a dollar sign
|
||||
* empty() function that checks for blank or non-existing fields
|
||||
*
|
||||
*
|
||||
*/
|
||||
function wpv_condition($atts) {
|
||||
extract(
|
||||
shortcode_atts( array('evaluate' => FALSE), $atts )
|
||||
);
|
||||
|
||||
global $post;
|
||||
|
||||
// if in admin, get the post from the URL
|
||||
if(is_admin()) {
|
||||
// Get post
|
||||
if (isset($_GET['post'])) {
|
||||
$post_id = (int) $_GET['post'];
|
||||
} else if (isset($_POST['post_ID'])) {
|
||||
$post_id = (int) $_POST['post_ID'];
|
||||
} else {
|
||||
$post_id = 0;
|
||||
}
|
||||
if ($post_id) {
|
||||
$post = get_post($post_id);
|
||||
}
|
||||
}
|
||||
|
||||
global $wplogger;
|
||||
|
||||
$logging_string = "Original expression: ". $evaluate;
|
||||
|
||||
// evaluate empty() statements for variables
|
||||
$empties = preg_match_all("/empty\(\s*\\$(\w+)\s*\)/", $evaluate, $matches);
|
||||
|
||||
if($empties && $empties > 0) {
|
||||
for($i = 0; $i < $empties; $i++) {
|
||||
$match_var = get_post_meta($post->ID, $atts[$matches[1][$i]], true);
|
||||
$is_empty = '1=0';
|
||||
|
||||
// mark as empty only nulls and ""
|
||||
if(is_null($match_var) || strlen($match_var) == 0) {
|
||||
$is_empty = '1=1';
|
||||
}
|
||||
|
||||
$evaluate = str_replace($matches[0][$i], $is_empty, $evaluate);
|
||||
}
|
||||
}
|
||||
|
||||
// find string variables and evaluate
|
||||
$strings_count = preg_match_all('/((\$\w+)|(\'[^\']*\'))\s*([\!<>\=]+)\s*((\$\w+)|(\'[^\']*\'))/', $evaluate, $matches);
|
||||
|
||||
// get all string comparisons - with variables and/or literals
|
||||
if($strings_count && $strings_count > 0) {
|
||||
for($i = 0; $i < $strings_count; $i++) {
|
||||
|
||||
// get both sides and sign
|
||||
$first_string = $matches[1][$i];
|
||||
$second_string = $matches[5][$i];
|
||||
$math_sign = $matches[4][$i];
|
||||
|
||||
// replace variables with text representation
|
||||
if(strpos($first_string, '$') === 0) {
|
||||
$variable_name = substr($first_string, 1); // omit dollar sign
|
||||
$first_string = get_post_meta($post->ID, $atts[$variable_name], true);
|
||||
}
|
||||
if(strpos($second_string, '$') === 0) {
|
||||
$variable_name = substr($second_string, 1);
|
||||
$second_string = get_post_meta($post->ID, $atts[$variable_name], true);
|
||||
}
|
||||
|
||||
// remove single quotes from string literals to get value only
|
||||
$first_string = (strpos($first_string, '\'') === 0) ? substr($first_string, 1, strlen($first_string) - 2) : $first_string;
|
||||
$second_string = (strpos($second_string, '\'') === 0) ? substr($second_string, 1, strlen($second_string) - 2) : $second_string;
|
||||
|
||||
// don't do string comparison if variables are numbers
|
||||
if(!(is_numeric($first_string) && is_numeric($second_string))) {
|
||||
// compare string and return true or false
|
||||
$compared_str_result = wpv_compare_strings($first_string, $second_string, $math_sign);
|
||||
|
||||
if($compared_str_result) {
|
||||
$evaluate = str_replace($matches[0][$i], '1=1', $evaluate);
|
||||
} else {
|
||||
$evaluate = str_replace($matches[0][$i], '1=0', $evaluate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// find all variable placeholders in expression
|
||||
$count = preg_match_all('/\$(\w+)/', $evaluate, $matches);
|
||||
|
||||
$logging_string .= "; Variable placeholders: ". var_export($matches[1], true);
|
||||
|
||||
// replace all variables with their values listed as shortcode parameters
|
||||
if($count && $count > 0) {
|
||||
// sort array by length desc, fix str_replace incorrect replacement
|
||||
$matches[1] = wpv_sort_matches_by_length($matches[1]);
|
||||
|
||||
foreach($matches[1] as $match) {
|
||||
$meta = get_post_meta($post->ID, $atts[$match], true);
|
||||
if (empty($meta)) {
|
||||
$meta = "0";
|
||||
}
|
||||
$evaluate = str_replace('$'.$match, $meta, $evaluate);
|
||||
}
|
||||
}
|
||||
|
||||
$logging_string .= "; End evaluated expression: ". $evaluate;
|
||||
|
||||
$wplogger->log($logging_string, WPLOG_DEBUG);
|
||||
// evaluate the prepared expression using the custom eval script
|
||||
$result = wpv_evaluate_expression($evaluate);
|
||||
|
||||
// return true, false or error string to the conditional caller
|
||||
return $result;
|
||||
}
|
||||
|
||||
function wpv_eval_check_syntax($code) {
|
||||
return @eval('return true;' . $code);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Sort matches array by length so evaluate longest variable names first
|
||||
*
|
||||
* Otherwise the str_replace would break a field named $f11 if there is another field named $f1
|
||||
*
|
||||
* @param array $matches all variable names
|
||||
*/
|
||||
function wpv_sort_matches_by_length($matches) {
|
||||
$length = count($matches);
|
||||
for($i = 0; $i < $length; $i++) {
|
||||
$max = strlen($matches[$i]);
|
||||
$max_index = $i;
|
||||
|
||||
// find the longest variable
|
||||
for($j = $i+1; $j < $length; $j++) {
|
||||
if(strlen($matches[$j]) > $max ) {
|
||||
$max = $matches[$j];
|
||||
$max_index = $j;
|
||||
}
|
||||
}
|
||||
|
||||
// swap
|
||||
$temp = $matches[$i];
|
||||
$matches[$i] = $matches[$max_index];
|
||||
$matches[$max_index] = $temp;
|
||||
}
|
||||
|
||||
return $matches;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Boolean function for string comparison
|
||||
*
|
||||
* @param string $first first string to be compared
|
||||
* @param string $second second string for comparison
|
||||
*
|
||||
*
|
||||
*/
|
||||
function wpv_compare_strings($first, $second, $sign) {
|
||||
// get comparison results
|
||||
$comparison = strcmp($first, $second);
|
||||
|
||||
// verify cases 'less than' and 'less than or equal': <, <=
|
||||
if($comparison < 0 && ($sign == '<' || $sign == '<=')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// verify cases 'greater than' and 'greater than or equal': >, >=
|
||||
if($comparison > 0 && ($sign == '>' || $sign == '>=')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// verify equal cases: =, <=, >=
|
||||
if($comparison == 0 && ($sign == '=' || $sign == '<=' || $sign == '>=') ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// verify != case
|
||||
if($comparison != 0 && $sign == '!=' ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// or result is incorrect
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Function that prepares the expression and calls eval()
|
||||
* Validates the input for a list of whitechars and handles internal errors if any
|
||||
*
|
||||
* @param string $expression the expression to be evaluated
|
||||
*/
|
||||
function wpv_evaluate_expression($expression){
|
||||
//Replace AND, OR, ==
|
||||
$expression = strtoupper($expression);
|
||||
$expression = str_replace("AND", "&&", $expression);
|
||||
$expression = str_replace("OR", "||", $expression);
|
||||
$expression = str_replace("NOT", "!", $expression);
|
||||
$expression = str_replace("=", "==", $expression);
|
||||
$expression = str_replace("<==", "<=", $expression);
|
||||
$expression = str_replace(">==", ">=", $expression);
|
||||
$expression = str_replace("!==", "!=", $expression); // due to the line above
|
||||
|
||||
// validate against allowed input characters
|
||||
$count = preg_match('/[0-9+-\=\*\/<>&\!\|\s\(\)]+/', $expression, $matches);
|
||||
|
||||
// find out if there is full match for the entire expression
|
||||
if($count > 0) {
|
||||
if(strlen($matches[0]) == strlen($expression)) {
|
||||
$valid_eval = wpv_eval_check_syntax("return $expression;");
|
||||
if($valid_eval) {
|
||||
return eval("return $expression;");
|
||||
}
|
||||
else {
|
||||
return __("Error while parsing the evaluate expression", 'wpv-views');
|
||||
}
|
||||
}
|
||||
else {
|
||||
return __("Conditional expression includes illegal characters", 'wpv-views');
|
||||
}
|
||||
}
|
||||
else {
|
||||
return __("Correct conditional expression has not been found", 'wpv-views');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* class WPV_wpcf_switch_post_from_attr_id
|
||||
*
|
||||
* This class handles the "id" attribute in a wpv-post-xxxxx shortcode
|
||||
* and sets the global $id, $post, and $authordata
|
||||
*
|
||||
* It also handles types. eg [types field='my-field' id='233']
|
||||
*
|
||||
* id can be a integer to refer directly to a post
|
||||
* id can be $parent to refer to the parent
|
||||
*
|
||||
* id can also refer to a related post type
|
||||
* eg. for a stay the related post types could be guest and room
|
||||
* [types field='my-field' id='$guest']
|
||||
* [types field='my-field' id='$room']
|
||||
*/
|
||||
|
||||
class WPV_wpcf_switch_post_from_attr_id {
|
||||
|
||||
function __construct($atts){
|
||||
$this->found = false;
|
||||
|
||||
if (isset($atts['id'])) {
|
||||
|
||||
global $post, $authordata, $id, $WPV_wpcf_post_relationship;
|
||||
|
||||
$post_id = 0;
|
||||
|
||||
if (strpos($atts['id'], '$') === 0) {
|
||||
// Handle the parent if the id is $parent
|
||||
if ($atts['id'] == '$parent' && isset($post->post_parent)) {
|
||||
$post_id = $post->post_parent;
|
||||
} else {
|
||||
// See if Views has the variable
|
||||
global $WP_Views;
|
||||
if (isset($WP_Views)) {
|
||||
$post_id = $WP_Views->get_variable($atts['id'] . '_id');
|
||||
}
|
||||
if ($post_id == 0) {
|
||||
// Try the local storage.
|
||||
if (isset($WPV_wpcf_post_relationship[$atts['id'] . '_id'])) {
|
||||
$post_id = $WPV_wpcf_post_relationship[$atts['id'] . '_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$post_id = intval($atts['id']);
|
||||
}
|
||||
|
||||
if ($post_id > 0) {
|
||||
|
||||
$this->found = true;
|
||||
|
||||
// save original post
|
||||
$this->post = isset($post) ? clone $post : null;
|
||||
if ($authordata) {
|
||||
$this->authordata = clone $authordata;
|
||||
} else {
|
||||
$this->authordata = null;
|
||||
}
|
||||
$this->id = $id;
|
||||
|
||||
// set the global post values
|
||||
$id = $post_id;
|
||||
$post = get_post($id);
|
||||
$authordata = new WP_User($post->post_author);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function __destruct(){
|
||||
if ($this->found) {
|
||||
global $post, $authordata, $id;
|
||||
|
||||
// restore the global post values.
|
||||
$post = isset($this->post) ? clone $this->post : null;
|
||||
if ($this->authordata) {
|
||||
$authordata = clone $this->authordata;
|
||||
} else {
|
||||
$authordata = null;
|
||||
}
|
||||
$id = $this->id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Add a filter on the content so that we can record any related posts.
|
||||
// These can then be used ine id of Types and Views shortcodes
|
||||
// eg. for a stay we can have
|
||||
// [types field='my-field' id="$room"] displays my-field from the related room
|
||||
// [wpv-post-title id="$room"] display the title of the related room
|
||||
|
||||
add_filter('the_content', 'WPV_wpcf_record_post_relationship_belongs', 0, 1);
|
||||
|
||||
$WPV_wpcf_post_relationship = Array();
|
||||
|
||||
function WPV_wpcf_record_post_relationship_belongs($content) {
|
||||
|
||||
global $post, $WPV_wpcf_post_relationship;
|
||||
static $related = array();
|
||||
|
||||
if (isset($post) && function_exists('wpcf_pr_get_belongs')) {
|
||||
|
||||
if (!isset($related[$post->post_type])) {
|
||||
$related[$post->post_type] = wpcf_pr_get_belongs($post->post_type);
|
||||
}
|
||||
if (is_array($related[$post->post_type])) {
|
||||
foreach($related[$post->post_type] as $post_type => $data) {
|
||||
$related_id = wpcf_pr_post_get_belongs($post->ID, $post_type);
|
||||
if ($related_id) {
|
||||
$WPV_wpcf_post_relationship['$' . $post_type . '_id'] = $related_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $content;
|
||||
}
|
||||
@ -1,91 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!function_exists('promote_types_and_views')) {
|
||||
|
||||
function is_promote_views() {
|
||||
$promote_views = false;
|
||||
if (defined('WPV_VERSION')) {
|
||||
global $WP_Views;
|
||||
$promote_views = $WP_Views->is_embedded();
|
||||
}
|
||||
return $promote_views;
|
||||
}
|
||||
|
||||
function promote_types_and_views() {
|
||||
static $promoted = false;
|
||||
|
||||
if (!$promoted) {
|
||||
$promote_types = defined('WPCF_RUNNING_EMBEDDED');
|
||||
$promote_views = is_promote_views();
|
||||
|
||||
if ($promote_types || $promote_views) {
|
||||
add_action('admin_menu', 'promote_types_and_views_menu');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function promote_types_and_views_menu() {
|
||||
$promote_types = defined('WPCF_RUNNING_EMBEDDED');
|
||||
$promote_views = is_promote_views();
|
||||
if ($promote_types || $promote_views) {
|
||||
add_theme_page(__('Get Types and Views', 'wpv-views'), 'Get Types and Views', 'manage_options', 'wpv-get-types-views', 'promote_types_and_views_admin');
|
||||
}
|
||||
}
|
||||
|
||||
function promote_types_and_views_admin() {
|
||||
?>
|
||||
<div class="wrap">
|
||||
<?php
|
||||
|
||||
$promote_types = defined('WPCF_RUNNING_EMBEDDED');
|
||||
$promote_views = is_promote_views();
|
||||
$affiliate_url = '';
|
||||
if (function_exists('wpv_get_affiliate_url')) {
|
||||
$affiliate_url = wpv_get_affiliate_url();
|
||||
}
|
||||
|
||||
$icon_url = icl_get_file_relpath(dirname(__FILE__) . '/res/img/views-32.png') . '/views-32.png';
|
||||
?>
|
||||
<div class="icon32" style='background:url("<?php echo $icon_url; ?>") no-repeat;'><br /></div>
|
||||
<h2><?php _e('Get Types and Views', 'wpv-views') ?></h2>
|
||||
|
||||
<p style="font-size: 130%;"><?php _e('Your theme was created using <strong>Types</strong> and <strong>Views</strong>. Developers use these two plugins to build complex websites, without coding.', 'wpv-views'); ?></p>
|
||||
<p style="font-size: 120%;"><?php _e("Right now, you're using the embedded version, which creates the layout but doesn't include the editing interface. You can upgrade to the full version and customize your site yourself - you don't even need to know how to program!", 'wpv-views'); ?></p>
|
||||
|
||||
<p style="font-size: 120%;"><?php echo sprintf(__('<a href="%s" target="_blank">Types</a> is available for free and <a href="%s">Views</a> costs only $49. Once you have installed the full versions of Types and Views you\'ll be able to create and edit your own content types, layouts and listings.', 'wpv-views'),
|
||||
'http://wordpress.org/extend/plugins/types/',
|
||||
'http://wp-types.com' . $affiliate_url); ?></p>
|
||||
|
||||
<p style="font-size: 140%; font-weight: bold; "><?php echo sprintf(__('<a href="%s" target="_blank">Learn more</a>', 'wpv-views'),
|
||||
'http://wp-types.com' . $affiliate_url); ?></p>
|
||||
|
||||
<br /><hr /><br />
|
||||
<ol>
|
||||
<li><?php _e('Every purchase of Views entitles you to commercial-grade support and upgrades for one year.','wpv-views'); ?></li>
|
||||
<li><?php _e('You can use Types and Views for as many themes and websites as you like.','wpv-views'); ?></li>
|
||||
</ol>
|
||||
|
||||
<?php
|
||||
|
||||
//if ($promote_types && $promote_views) {
|
||||
//
|
||||
// wpv_promote_views_admin();
|
||||
// echo "<hr />\n";
|
||||
// wpcf_promote_types_admin();
|
||||
//} else {
|
||||
// if ($promote_types) {
|
||||
// wpcf_promote_types_admin();
|
||||
// } else {
|
||||
// wpv_promote_views_admin();
|
||||
// }
|
||||
//}
|
||||
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 2.1 KiB |
@ -1,519 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!class_exists('Editor_addon')) {
|
||||
|
||||
if (!defined('ICL_COMMON_FUNCTIONS')) {
|
||||
require_once dirname(dirname(__FILE__)) . '/functions.php';
|
||||
}
|
||||
|
||||
define('EDITOR_ADDON_ABSPATH', dirname(__FILE__));
|
||||
if (!defined('EDITOR_ADDON_RELPATH')) {
|
||||
define('EDITOR_ADDON_RELPATH', icl_get_file_relpath(__FILE__));
|
||||
}
|
||||
add_action('admin_print_styles', 'add_menu_css');
|
||||
|
||||
function add_menu_css() {
|
||||
global $pagenow;
|
||||
|
||||
if ($pagenow == 'post.php' || $pagenow == 'post-new.php') {
|
||||
wp_enqueue_style('editor_addon_menu',
|
||||
EDITOR_ADDON_RELPATH . '/res/css/pro_dropdown_2.css');
|
||||
wp_enqueue_style('editor_addon_menu_scroll',
|
||||
EDITOR_ADDON_RELPATH . '/res/css/scroll.css');
|
||||
}
|
||||
}
|
||||
|
||||
if (is_admin()) {
|
||||
add_action('admin_print_scripts', 'editor_add_js');
|
||||
}
|
||||
|
||||
class Editor_addon
|
||||
{
|
||||
|
||||
function __construct($name, $button_text, $plugin_js_url,
|
||||
$media_button_image = '') {
|
||||
|
||||
$this->name = $name;
|
||||
$this->plugin_js_url = $plugin_js_url;
|
||||
$this->button_text = $button_text;
|
||||
$this->media_button_image = $media_button_image;
|
||||
$this->initialized = false;
|
||||
|
||||
$this->items = array();
|
||||
|
||||
if ($media_button_image != '') {
|
||||
// Media buttons
|
||||
//Adding "embed form" button
|
||||
// WP 3.3 changes
|
||||
global $wp_version;
|
||||
if (version_compare($wp_version, '3.1.4', '>')) {
|
||||
add_action('media_buttons', array($this, 'add_form_button'),
|
||||
10, 2);
|
||||
} else {
|
||||
add_action('media_buttons_context',
|
||||
array($this, 'add_form_button'), 10, 2);
|
||||
}
|
||||
}
|
||||
|
||||
// add_action('media_buttons', array($this, 'media_buttons'), 11);
|
||||
// wp_enqueue_style('editor_addon', plugins_url() . '/' . basename(dirname(dirname(dirname(__FILE__)))) . '/common/' . basename(dirname(__FILE__)) . '/res/css/style.css');
|
||||
}
|
||||
|
||||
function __destruct() {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Add a menu item that will insert the shortcode.
|
||||
|
||||
To use sub menus, add a '-!-' separator between levels in
|
||||
the $menu parameter.
|
||||
eg. Field-!-image
|
||||
This will create/use a menu "Field" and add a sub menu "image"
|
||||
|
||||
$function_name is the javascript function to call for the on-click
|
||||
If it's left blank then a function will be created that just
|
||||
inserts the shortcode.
|
||||
|
||||
*/
|
||||
|
||||
function add_insert_shortcode_menu($text, $shortcode, $menu,
|
||||
$function_name = '') {
|
||||
$this->items[] = array($text, $shortcode, $menu, $function_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding a "V" button to the menu
|
||||
* @param string $context
|
||||
* @param string $text_area
|
||||
* @param boolean $standard_v is this a standard V button
|
||||
*/
|
||||
function add_form_button($context, $text_area = 'textarea#content', $standard_v = TRUE) {
|
||||
global $wp_version;
|
||||
// WP 3.3 changes ($context arg is actually a editor ID now)
|
||||
if (version_compare($wp_version, '3.1.4', '>') && !empty($context)) {
|
||||
$text_area = $context;
|
||||
}
|
||||
|
||||
// Apply filters
|
||||
$this->items = apply_filters('editor_addon_items_' . $this->name,
|
||||
$this->items);
|
||||
|
||||
// add_filter('editor_addon_parent_items', array($this, 'wpv_add_parent_items'), 10, $this->items);
|
||||
// Apply filter parent items
|
||||
//apply_filters('editor_addon_parent_items', $this->items);
|
||||
// sort the items into menu levels.
|
||||
|
||||
$menus = array();
|
||||
$sub_menus = array();
|
||||
|
||||
foreach ($this->items as $item) {
|
||||
$parts = explode('-!-', $item[2]);
|
||||
$menu_level = &$menus;
|
||||
foreach ($parts as $part) {
|
||||
if ($part != '') {
|
||||
if (!array_key_exists($part, $menu_level)) {
|
||||
$menu_level[$part] = array();
|
||||
}
|
||||
$menu_level = &$menu_level[$part];
|
||||
}
|
||||
}
|
||||
$menu_level[$item[0]] = $item;
|
||||
}
|
||||
|
||||
// Apply filters
|
||||
$menus = apply_filters('editor_addon_menus_' . $this->name, $menus);
|
||||
|
||||
// add View Template links to the "Add Field" button
|
||||
if(!$standard_v) {
|
||||
$this->add_view_templates($menus);
|
||||
}
|
||||
|
||||
// Sort menus
|
||||
if(is_array($menus)) {
|
||||
$menus = $this->sort_menus_alphabetically($menus);
|
||||
}
|
||||
|
||||
|
||||
$this->_media_menu_direct_links = array();
|
||||
$menus_output = $this->_output_media_menu($menus, $text_area, $standard_v);
|
||||
|
||||
$direct_links = implode(' ', $this->_media_menu_direct_links);
|
||||
|
||||
$addon_button = '<img src="' . $this->media_button_image . '">';
|
||||
if(!$standard_v) {
|
||||
$addon_button = '<img src="' . $this->media_button_image . '" class="vicon">';
|
||||
// $addon_button = '<input id="addingbutton" alt="#TB_inline?inlineId=add_field_popup" class="thickbox wpv_add_fields_button button-primary field_adder" type="button" value="'. __('Add field', 'wpv-views') .'" name="">';
|
||||
//$addon_button = '<span class="wpv_add_fields_button button-primary field_adder">'. __('Add field', 'wpv-views') .'</span>';
|
||||
}
|
||||
|
||||
// add search box
|
||||
$searchbar = $this->get_search_bar();
|
||||
|
||||
// generate output content
|
||||
$out = '
|
||||
<ul class="editor_addon_wrapper"><li>' . $addon_button . '<ul class="editor_addon_dropdown"><li><div class="title">'
|
||||
. $this->button_text
|
||||
. '</div><div class="close"> </div></li><li><div>'
|
||||
. apply_filters('editor_addon_dropdown_top_message_' . $this->name, '')
|
||||
. '</div><div class="direct-links">'
|
||||
. $direct_links . '</div>' .$searchbar. '<div class="scroll"><div class="wrapper">'
|
||||
. $menus_output . '</div><div></div>'
|
||||
. apply_filters('editor_addon_dropdown_bottom_message' . $this->name, '')
|
||||
. '</div></li></ul></li></ul>';
|
||||
|
||||
// WP 3.3 changes
|
||||
if (version_compare($wp_version, '3.1.4', '>')) {
|
||||
echo apply_filters('wpv_add_media_buttons', $out);
|
||||
} else {
|
||||
return apply_filters('wpv_add_media_buttons', $context . $out);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a single menu item
|
||||
* @param string $menu
|
||||
* @param string $text_area
|
||||
* @param boolean $standard_v
|
||||
* @return string media menu
|
||||
*/
|
||||
function _output_media_menu($menu, $text_area, $standard_v) {
|
||||
$out = '';
|
||||
if (is_array($menu)) {
|
||||
foreach ($menu as $key => $menu_item) {
|
||||
if (isset($menu_item[0]) && !is_array($menu_item[0])) {
|
||||
if(!isset($menu_item[3])) { break; }
|
||||
if ($menu_item[3] != '') {
|
||||
if(!($key == 'css')) { // hide unnecessary elements from the V popup
|
||||
if(!$standard_v && (strpos($menu_item[3], 'wpcfFieldsEditorCallback') !== false || (strpos($menu_item[3], 'wpcfFieldsEmailEditorCallback') !== false))) {
|
||||
$out .= $this->wpv_parse_menu_item_from_addfield($menu_item);
|
||||
} else {
|
||||
$out .= '<a href="javascript:void(0);" class="item" onclick="' . $menu_item[3] . '; return false;">' . $menu_item[0] . "</a>\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$short_code = '[' . $menu_item[1] . ']';
|
||||
$short_code = base64_encode($short_code);
|
||||
// echo "<pre>";
|
||||
// var_dump($menu);
|
||||
// echo "</pre>";
|
||||
if($standard_v) {
|
||||
$out .= '<a href="#" class="item" onclick="insert_b64_shortcode_to_editor(\'' . $short_code . '\', \'' . $text_area . '\'); return false;">' . $menu_item[0] . "</a>\n";
|
||||
} else {
|
||||
$out .= $this->wpv_parse_menu_item_from_addfield($menu_item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// a sum menu.
|
||||
$css_classes = isset($menu_item['css']) ? $menu_item['css'] : '';
|
||||
if($key == __('Taxonomy', 'wpv-views')) {
|
||||
$css_classes = 'taxonomy';
|
||||
}
|
||||
$this->_media_menu_direct_links[] = '<a href="#" class="editor-addon-top-link" id="editor-addon-link-' . md5($key) . '">' . $key . ' </a>';
|
||||
$out .= '<div class="group '. $css_classes .'"><div class="group-title" id="editor-addon-link-' . md5($key) . '-target">' . $key . " \n</div>\n";
|
||||
$out .= $this->_output_media_menu($menu_item, $text_area, $standard_v);
|
||||
$out .= "</div>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parser for menu items in the add-field
|
||||
* @param unknown_type $key
|
||||
* @param unknown_type $menu_item
|
||||
* @return string
|
||||
*/
|
||||
function wpv_parse_menu_item_from_addfield($menu_item) {
|
||||
$param1 = '';
|
||||
$slug = $menu_item[1];
|
||||
|
||||
// search for wpv- starting fields first
|
||||
if(strpos($slug, 'wpv-') !== false) {
|
||||
$menuitem_parts = explode(' ', $slug);
|
||||
$slug = $menuitem_parts[0];
|
||||
}
|
||||
// find types fields
|
||||
else if((preg_match('/types field="(.+)"/', $slug, $matches) > 0)
|
||||
|| (preg_match('/type="(.+)"/', $slug, $matches) > 0)
|
||||
|| (strpos($slug, 'wpcfFieldsEditorCallback') !== false)
|
||||
|| (strpos($slug, 'wpcfFieldsEmailEditorCallback') !== false)) {
|
||||
$types_slug = $matches[1];
|
||||
$types_slug = str_replace('" class="" style="', '', $types_slug);
|
||||
// convert Types fields to Views fields
|
||||
$slug = $types_slug;
|
||||
$param1 = 'Types-!-wpcf';
|
||||
}
|
||||
else if(preg_match('/type="(.+)"/', $slug, $matches) > 0) {
|
||||
$types_slug = $matches[1];
|
||||
$types_slug = str_replace('" class="" style="', '', $types_slug);
|
||||
// convert field to Views field
|
||||
$slug = $types_slug;
|
||||
$param1 = 'Types-!-wpcf';
|
||||
|
||||
// apply_filters() for Types shortcodes
|
||||
}
|
||||
// for Basic group fields
|
||||
if($menu_item[2] == __('Basic', 'wpv-views')) {
|
||||
// don't use slug here, just field name.
|
||||
$slug = $menu_item[0];
|
||||
}
|
||||
// View Templates here
|
||||
if($menu_item[2] == __('View templates', 'wpv-views')) {
|
||||
$param1 = 'View template';
|
||||
}
|
||||
if(strpos($slug, 'wpv-post-field') !== false) {
|
||||
$param1 = 'Field';
|
||||
$slug = $menu_item[0];
|
||||
}
|
||||
// Taxonomies
|
||||
if(strpos($menu_item[1], 'wpv-post-taxonomy') !== false) {
|
||||
$slug = $menu_item[1];
|
||||
$param1 = 'Taxonomy';
|
||||
if(preg_match('/wpv-post-taxonomy type="([^"]*)"/', $slug, $matches) > 0) {
|
||||
$slug = 'wpvtax-'.$matches[1]; // split up and pass text only
|
||||
} else {
|
||||
$slug = esc_html($menu_item[1]);
|
||||
$slug = str_replace('wpv-post-taxonomy', 'wpv-taxonomy', $slug);
|
||||
}
|
||||
/* $slug = esc_html($menu_item[1]);
|
||||
$slug = str_replace('wpv-post-taxonomy', 'wpv-taxonomy', $slug); */
|
||||
}
|
||||
|
||||
return '<a href="javascript:void(0);" class="item" onclick="on_add_field_wpv(\''. $param1 . '\', \'' . $slug . '\', \'' . base64_encode($menu_item[0]) . '\')">' . $menu_item[0] . "</a>\n";
|
||||
}
|
||||
|
||||
// add parent items for Views and View Templates
|
||||
function wpv_add_parent_items($items) {
|
||||
global $post, $pagenow;
|
||||
|
||||
if ($pagenow == 'post-new.php' && isset($_GET['post_type']) && $_GET['post_type'] == 'view-template') {
|
||||
$this->add_view_template_parent_groups($items);
|
||||
}
|
||||
if($pagenow == 'post-new.php' && isset($_GET['post_type']) && $_GET['post_type'] == 'view') {
|
||||
|
||||
}
|
||||
else if($pagenow == 'post.php' && isset($_GET['action']) && $_GET['action'] == 'edit') {
|
||||
$post_type = $post->post_type;
|
||||
|
||||
if($post_type == 'view') {
|
||||
$items = $this->add_view_parent_groups($items);
|
||||
}
|
||||
else if($post_type == 'view-template') {
|
||||
$items = $this->add_view_template_parent_groups($items);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
function add_view_parent_groups($items) {
|
||||
|
||||
}
|
||||
|
||||
// add parent groups for vew templates
|
||||
function add_view_template_parent_groups($items) {
|
||||
global $post;
|
||||
// get current View ID
|
||||
$view_template_id = $post->ID;
|
||||
|
||||
// get all view templates attached in the Settings page for single view
|
||||
$view_template_relations = $this->get_view_template_settings();
|
||||
|
||||
// find view template groups and get their parents
|
||||
$current_types = array();
|
||||
$parent_types = array();
|
||||
foreach($view_template_relations as $relation=>$value) {
|
||||
if($value == $view_template_id) {
|
||||
$current_types[] = $relation;
|
||||
if (function_exists('wpcf_pr_get_belongs')) {
|
||||
$parent_types[] = wpcf_pr_get_belongs($relation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get parent groups
|
||||
$all_parent_groups = array();
|
||||
foreach($parent_types as $type) {
|
||||
foreach($type as $typename=>$typeval) {
|
||||
$parent_groups = wpcf_admin_get_groups_by_post_type($typename);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
|
||||
Render the javascript code to define the menus
|
||||
The views_editor_plugin.js will use the created javascript
|
||||
variables to create the menu.
|
||||
|
||||
*/
|
||||
|
||||
function render_js() {
|
||||
if (sizeof($this->items) > 0) {
|
||||
$name = str_replace('-', '_', $this->name);
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var wp_editor_addon_<?php echo $name; ?> = new Array();
|
||||
var button_title = '<?php echo $this->button_text; ?>';
|
||||
<?php
|
||||
$index = 0;
|
||||
foreach ($this->items as $item) {
|
||||
$function_name = $name . base64_encode($item[0]) . '_' . $index;
|
||||
$function_name = str_replace(array('+', '/', '='), '_',
|
||||
$function_name);
|
||||
if ($item[3] != '') {
|
||||
// we need to create an on-click function that calls the function passed
|
||||
echo 'wp_editor_addon_' . $name . '[' . $index . '] = new Array("' . $item[0] . '", "' . $function_name . '", "' . $item[2] . '");' . "\n";
|
||||
|
||||
// create a js function to be called for the on_click
|
||||
echo 'function ' . $function_name . "() { " . $item[3] . "};\n";
|
||||
} else {
|
||||
// we need to create an on-click function that just inserts the shortcode.
|
||||
echo 'wp_editor_addon_' . $name . '[' . $index . '] = new Array("' . $item[0] . '", "' . $function_name . '", "' . $item[2] . '");' . "\n";
|
||||
|
||||
// create a js function to be called for the on_click
|
||||
echo 'function ' . $function_name . "() { tinyMCE.activeEditor.execCommand('mceInsertContent', false, '[" . $item[1] . "]')};\n";
|
||||
}
|
||||
|
||||
$index++;
|
||||
}
|
||||
|
||||
?>
|
||||
</script>
|
||||
<?php
|
||||
add_filter('mce_external_plugins',
|
||||
array($this, 'wpv_mce_register'));
|
||||
add_filter('mce_buttons', array($this, 'wpv_mce_add_button'), 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Add the wpv_views button to the toolbar.
|
||||
|
||||
*/
|
||||
|
||||
function wpv_mce_add_button($buttons)
|
||||
{
|
||||
array_push($buttons, "separator", str_replace('-', '_', $this->name));
|
||||
return $buttons;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Register this plugin as a mce 'addon'
|
||||
Tell the mce editor the url of the javascript file.
|
||||
*/
|
||||
|
||||
function wpv_mce_register($plugin_array)
|
||||
{
|
||||
$plugin_array[str_replace('-', '_', $this->name)] = $this->plugin_js_url;
|
||||
return $plugin_array;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Sort menus (and menu content) in an alphabetical order
|
||||
*
|
||||
* Still, keep Basic and Taxonomy on the top and Other Fields at the bottom
|
||||
*
|
||||
* @param array $menu menu reference
|
||||
*/
|
||||
function sort_menus_alphabetically($menus) {
|
||||
// keep main references if set (not set on every screen)
|
||||
$menu_basic[__('Basic', 'wpv-views')] = isset($menus[__('Basic', 'wpv-views')]) ? $menus[__('Basic', 'wpv-views')] : array();
|
||||
$menu_taxonomy[__('Taxonomy', 'wpv-views')] = isset($menus[__('Taxonomy', 'wpv-views')]) ? $menus[__('Taxonomy', 'wpv-views')] : array();
|
||||
$menu_field[__('Other Fields', 'wpv-views')] = isset($menus[__('Field', 'wpv-views')]) ? $menus[__('Field', 'wpv-views')] : array();
|
||||
$menu_vtemplate[__('View templates', 'wpv-views')] = isset($menus[__('View templates', 'wpv-views')]) ? $menus[__('View templates', 'wpv-views')] : array();
|
||||
|
||||
// remove them to preserve correct listing
|
||||
unset($menus[__('Basic', 'wpv-views')]);
|
||||
unset($menus[__('Taxonomy', 'wpv-views')]);
|
||||
unset($menus[__('Field', 'wpv-views')]);
|
||||
unset($menus[__('View templates', 'wpv-views')]);
|
||||
|
||||
// sort all elements by key
|
||||
ksort($menus);
|
||||
|
||||
// add main elements in the correct order
|
||||
$menus = !empty($menu_taxonomy[__('Taxonomy', 'wpv-views')]) ? array_merge($menu_taxonomy, $menus) : $menus;
|
||||
$menus = !empty($menu_vtemplate[__('View templates', 'wpv-views')]) ? array_merge($menu_vtemplate, $menus) : $menus;
|
||||
$menus = !empty($menu_basic[__('Basic', 'wpv-views')]) ? array_merge($menu_basic, $menus): $menus;
|
||||
$menus = !empty($menu_field[__('Other Fields', 'wpv-views')]) ? array_merge($menus, $menu_field) : $menus;
|
||||
|
||||
// sort inner elements in the submenus
|
||||
foreach($menus as $key=>$menu_group) {
|
||||
if(is_array($menu_group)) {
|
||||
ksort($menu_group);
|
||||
}
|
||||
}
|
||||
|
||||
return $menus;
|
||||
}
|
||||
|
||||
function get_search_bar() {
|
||||
$searchbar = '<div class="searchbar">';
|
||||
$searchbar .= '<span>'. __('Search', 'wpv-views') .': </span>';
|
||||
$searchbar .= '<input type="text" class="search_field" onkeyup="wpv_on_search_filter(this)" />';
|
||||
$searchbar .= '<input type="button" class="search_clear" value="'.__('Clear', 'wpv-views'). '" onclick="wpv_search_clear(this)" style="display: none;" />';
|
||||
$searchbar .= '</div>';
|
||||
|
||||
return $searchbar;
|
||||
}
|
||||
|
||||
function add_view_templates(&$menus) {
|
||||
global $wpdb;
|
||||
|
||||
$view_templates_available = $wpdb->get_results("SELECT ID, post_title, post_name FROM {$wpdb->posts} WHERE post_type='view-template' AND post_status in ('publish')");
|
||||
$menus[__('View templates', 'wpv-views')] = array();
|
||||
|
||||
$vtemplate_index = 0;
|
||||
foreach($view_templates_available as $vtemplate) {
|
||||
$menus[__('View templates', 'wpv-views')][$vtemplate_index] = array();
|
||||
$menus[__('View templates', 'wpv-views')][$vtemplate_index][] = $vtemplate->post_title;
|
||||
$menus[__('View templates', 'wpv-views')][$vtemplate_index][] = $vtemplate->post_name;
|
||||
$menus[__('View templates', 'wpv-views')][$vtemplate_index][] = __('View templates', 'wpv-views');
|
||||
$menus[__('View templates', 'wpv-views')][$vtemplate_index][] = '';
|
||||
$vtemplate_index++;
|
||||
}
|
||||
}
|
||||
|
||||
function get_view_template_settings() {
|
||||
$post_types = get_post_types();
|
||||
|
||||
$options = array();
|
||||
$wpv_options = get_option('wpv_options');
|
||||
|
||||
foreach($post_types as $type) {
|
||||
if(isset($wpv_options['views_template_for_'. $type]) && !empty($wpv_options['views_template_for_'. $type])) {
|
||||
$options[$type] = $wpv_options['views_template_for_'. $type];
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function editor_add_js() {
|
||||
global $pagenow;
|
||||
|
||||
if ($pagenow == 'post.php' || $pagenow == 'post-new.php') {
|
||||
|
||||
wp_enqueue_script('icl_editor-script',
|
||||
EDITOR_ADDON_RELPATH . '/res/js/icl_editor_addon_plugin.js',
|
||||
array());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,176 +0,0 @@
|
||||
/* ================================================================
|
||||
This copyright notice must be kept untouched in the stylesheet at
|
||||
all times.
|
||||
|
||||
The original version of this stylesheet and the associated (x)html
|
||||
is available at http://www.stunicholls.com/menu/pro_drop_2.html
|
||||
Copyright (c) 2005-2007 Stu Nicholls. All rights reserved.
|
||||
This stylesheet and the associated (x)html may be modified in any
|
||||
way to fit your requirements.
|
||||
=================================================================== */
|
||||
|
||||
.preload1 {background: url(../img/three_1.gif);}
|
||||
.preload2 {background: url(../img/three_1a.gif);}
|
||||
|
||||
#editor_addon {display: inline;}
|
||||
|
||||
#editor_addon li.top {display: inline;}
|
||||
#editor_addon li a.top_link {display: inline; cursor:pointer;}
|
||||
|
||||
/* Default list styling */
|
||||
|
||||
#editor_addon li:hover {position:relative; z-index:200;}
|
||||
|
||||
#editor_addon li:hover ul.sub
|
||||
{left:1px; top:18px; background: #ffffff; padding:3px; border:1px solid #5c731e; white-space:nowrap; width:90px; height:auto; z-index:300;}
|
||||
#editor_addon li:hover ul.sub li
|
||||
{display:block; height:20px; position:relative; float:left; width:90px; font-weight:normal;}
|
||||
#editor_addon li:hover ul.sub li a
|
||||
{display:block; font-size:11px; height:18px; width:88px; line-height:18px; text-indent:5px; color:#000; text-decoration:none;}
|
||||
#editor_addon li ul.sub li a.fly
|
||||
{background:#ffffff url(../img/arrow.gif) 80px 6px no-repeat;}
|
||||
#editor_addon li:hover ul.sub li a:hover
|
||||
{background:#6a812c; color:#fff; border-color:#fff;}
|
||||
#editor_addon li:hover ul.sub li a.fly:hover
|
||||
{background:#6a812c url(../img/arrow_over.gif) 80px 6px no-repeat; color:#fff;}
|
||||
|
||||
|
||||
#editor_addon li:hover li:hover ul,
|
||||
#editor_addon li:hover li:hover li:hover ul,
|
||||
#editor_addon li:hover li:hover li:hover li:hover ul,
|
||||
#editor_addon li:hover li:hover li:hover li:hover li:hover ul
|
||||
{left:90px; top:-4px; background: #ffffff; padding:3px; border:1px solid #5c731e; white-space:nowrap; width:90px; z-index:400; height:auto;}
|
||||
|
||||
#editor_addon ul,
|
||||
#editor_addon li:hover ul ul,
|
||||
#editor_addon li:hover li:hover ul ul,
|
||||
#editor_addon li:hover li:hover li:hover ul ul,
|
||||
#editor_addon li:hover li:hover li:hover li:hover ul ul
|
||||
{position:absolute; left:-9999px; top:-9999px; width:0; height:0; margin:0; padding:0; list-style:none;}
|
||||
|
||||
#editor_addon li:hover li:hover a.fly,
|
||||
#editor_addon li:hover li:hover li:hover a.fly,
|
||||
#editor_addon li:hover li:hover li:hover li:hover a.fly,
|
||||
#editor_addon li:hover li:hover li:hover li:hover li:hover a.fly
|
||||
{background:#ffffff url(../img/arrow_over.gif) 80px 6px no-repeat; color:#000; border-color:#fff;}
|
||||
|
||||
#editor_addon li:hover li:hover li a.fly,
|
||||
#editor_addon li:hover li:hover li:hover li a.fly,
|
||||
#editor_addon li:hover li:hover li:hover li:hover li a.fly
|
||||
{background:#ffffff url(../img/arrow.gif) 80px 6px no-repeat; color:#000; border-color:#bbd37e;}
|
||||
|
||||
.editor_addon_wrapper {
|
||||
display: inline;
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
.editor_addon_wrapper li {
|
||||
display: inline;
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
.editor_addon_wrapper img {
|
||||
margin: 0 2px;
|
||||
cursor: pointer;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.editor_addon_dropdown {
|
||||
display: inline;
|
||||
visibility: hidden;
|
||||
position: absolute;
|
||||
background-color: #FFFFFF;
|
||||
border: 1px solid #CCCCCC;
|
||||
padding: 0;
|
||||
z-index: 99;
|
||||
width: auto;
|
||||
height: auto;
|
||||
margin-top: 22px;
|
||||
margin-left: -16px;
|
||||
margin-right: 30px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.editor_addon_dropdown ul {
|
||||
list-style: none inside none;
|
||||
}
|
||||
|
||||
.editor_addon_dropdown li {
|
||||
padding: 5px 20px 20px 20px;
|
||||
margin: 0;
|
||||
display: block;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.editor_addon_dropdown li:first-child {
|
||||
padding: 5px 10px;
|
||||
margin: 0;
|
||||
background-color: #EFEFEF;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.editor_addon_dropdown .title {
|
||||
font-weight: bold;
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.editor_addon_dropdown .close {
|
||||
width: 11px;
|
||||
height: 11px;
|
||||
background-image: url(../img/close_icon.gif);
|
||||
float: right;
|
||||
margin: -15px -5px 0 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.editor_addon_dropdown .scroll {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
overflow: auto;
|
||||
overflow-x: hidden;
|
||||
-ms-overflow-x: hidden;
|
||||
}
|
||||
|
||||
.editor_addon_dropdown .scroll .wrapper {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.editor_addon_dropdown .group-title {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.editor-addon-link-to-top {
|
||||
font-weight: normal;
|
||||
color: #909090;
|
||||
}
|
||||
|
||||
.editor_addon_dropdown .group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.editor_addon_dropdown .group .group .group-title {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.editor_addon_dropdown .group .group {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.editor_addon_dropdown .item {
|
||||
margin: 0 0 0 10px;
|
||||
line-height: 1.8em;
|
||||
white-space: nowrap;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.editor_addon_dropdown .direct-links {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.editor_addon_dropdown .direct-links a {
|
||||
font-weight: normal;
|
||||
line-height: 1.8em;
|
||||
margin-right: 10px;
|
||||
padding: 0;
|
||||
color: #909090 !important;
|
||||
}
|
||||
@ -1,122 +0,0 @@
|
||||
/*Scrollbar*/
|
||||
/*
|
||||
* CSS Styles that are needed by jScrollPane for it to operate correctly.
|
||||
*
|
||||
* Include this stylesheet in your site or copy and paste the styles below into your stylesheet - jScrollPane
|
||||
* may not operate correctly without them.
|
||||
*/
|
||||
|
||||
.jspContainer
|
||||
{
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.jspPane
|
||||
{
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.jspVerticalBar
|
||||
{
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 11px;
|
||||
height: 100%;
|
||||
background: red;
|
||||
}
|
||||
|
||||
.jspHorizontalBar
|
||||
{
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 11px;
|
||||
background: red;
|
||||
}
|
||||
|
||||
.jspVerticalBar *,
|
||||
.jspHorizontalBar *
|
||||
{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.jspCap
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.jspHorizontalBar .jspCap
|
||||
{
|
||||
float: left;
|
||||
}
|
||||
|
||||
.jspTrack
|
||||
{
|
||||
background: #F5F5F5;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.jspDrag
|
||||
{
|
||||
background: #EDEDED;
|
||||
position: relative;
|
||||
top: 0;
|
||||
left: 0;
|
||||
cursor: pointer;
|
||||
border: 1px solid #E0E0E0;
|
||||
}
|
||||
|
||||
.jspHorizontalBar .jspTrack,
|
||||
.jspHorizontalBar .jspDrag
|
||||
{
|
||||
float: left;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.jspArrow
|
||||
{
|
||||
background: #E1E1E1;
|
||||
text-indent: -20000px;
|
||||
display: block;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.jspArrow.jspDisabled
|
||||
{
|
||||
cursor: default;
|
||||
background: #80808d;
|
||||
}
|
||||
|
||||
.jspVerticalBar .jspArrow
|
||||
{
|
||||
height: 11px;
|
||||
}
|
||||
|
||||
.jspHorizontalBar .jspArrow
|
||||
{
|
||||
width: 11px;
|
||||
float: left;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.jspVerticalBar .jspArrow:focus
|
||||
{
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.jspCorner
|
||||
{
|
||||
background: #eeeef4;
|
||||
float: left;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/* Yuk! CSS Hack for IE6 3 pixel bug :( */
|
||||
* html .jspCorner
|
||||
{
|
||||
margin: 0 -3px 0 0;
|
||||
}
|
||||
|
Before Width: | Height: | Size: 49 B |
|
Before Width: | Height: | Size: 49 B |
|
Before Width: | Height: | Size: 128 B |
|
Before Width: | Height: | Size: 232 B |
|
Before Width: | Height: | Size: 897 B |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
@ -1,383 +0,0 @@
|
||||
jQuery(document).ready(function(){
|
||||
// Set active editor
|
||||
window.wpcfActiveEditor = false;
|
||||
jQuery('.wpcf-wysiwyg .editor_addon_wrapper .item, #postdivrich .editor_addon_wrapper .item').click(function(){
|
||||
window.wpcfActiveEditor = jQuery(this).parents('.wpcf-wysiwyg, #postdivrich').find('textarea').attr('id');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function icl_editor_add_menu(c, m, icl_editor_menu) {
|
||||
Array.prototype.isKey = function(){
|
||||
for(i in this){
|
||||
if(i === arguments[0])
|
||||
return true;
|
||||
};
|
||||
return false;
|
||||
};
|
||||
|
||||
var sub_menus = new Array();
|
||||
for (var index = 0; index < icl_editor_menu.length; index++) {
|
||||
|
||||
// Set callback function
|
||||
var fn = icl_editor_menu[index][1];
|
||||
|
||||
if (icl_editor_menu[index][2] != "") {
|
||||
// a sub menu
|
||||
|
||||
|
||||
if (sub_menus.isKey(icl_editor_menu[index][2])) {
|
||||
sub = sub_menus[icl_editor_menu[index][2]];
|
||||
} else {
|
||||
// Create a sub menu/s
|
||||
parts = icl_editor_menu[index][2].split('-!-');
|
||||
sub = m;
|
||||
name = '';
|
||||
for (var part = 0; part < parts.length; part++) {
|
||||
if (name == '') {
|
||||
name = parts[part];
|
||||
} else {
|
||||
name += '-!-' + parts[part];
|
||||
}
|
||||
if (sub_menus.isKey(name)) {
|
||||
sub = sub_menus[name];
|
||||
} else {
|
||||
sub = sub.addMenu({
|
||||
title : parts[part]
|
||||
});
|
||||
sub_menus[name] = sub;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub.add({
|
||||
title : icl_editor_menu[index][0],
|
||||
onclick : eval(fn)
|
||||
});
|
||||
|
||||
} else {
|
||||
m.add({
|
||||
title : icl_editor_menu[index][0],
|
||||
onclick : eval(fn)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// return c;
|
||||
}
|
||||
|
||||
jQuery.fn.extend({
|
||||
insertAtCaret: function(myValue){
|
||||
return this.each(function(i) {
|
||||
if (document.selection) {
|
||||
this.focus();
|
||||
sel = document.selection.createRange();
|
||||
sel.text = myValue;
|
||||
this.focus();
|
||||
}
|
||||
else if (this.selectionStart || this.selectionStart == '0') {
|
||||
var startPos = this.selectionStart;
|
||||
var endPos = this.selectionEnd;
|
||||
var scrollTop = this.scrollTop;
|
||||
this.value = this.value.substring(0, startPos)+myValue+this.value.substring(endPos,this.value.length);
|
||||
this.focus();
|
||||
this.selectionStart = startPos + myValue.length;
|
||||
this.selectionEnd = startPos + myValue.length;
|
||||
this.scrollTop = scrollTop;
|
||||
} else {
|
||||
this.value += myValue;
|
||||
this.focus();
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
jQuery(window).load(function(){
|
||||
// handle the "Add Field" boxes - some layout changes
|
||||
jQuery('.wpv_add_fields_button').click(function(e) {
|
||||
var dropdown_list = jQuery('#add_field_popup .editor_addon_dropdown');
|
||||
jQuery('#add_field_popup .editor_addon_wrapper .vicon').css('display', 'none');
|
||||
dropdown_list.css('height', '470px');
|
||||
dropdown_list.css('width', '100%');
|
||||
dropdown_list.css('margin', '-2px 0 0 -15px');
|
||||
dropdown_list.css('padding', '0px');
|
||||
dropdown_list.css('overflow', 'auto');
|
||||
dropdown_list.css('visibility', 'visible');
|
||||
|
||||
jQuery('#add_field_popup .editor_addon_wrapper .close').css('display', 'none');
|
||||
|
||||
wpv_hide_top_groups(jQuery(dropdown_list).parent());
|
||||
|
||||
var ajaxWrapper = jQuery(dropdown_list).parent().parent().parent();
|
||||
ajaxWrapper.css('padding', '0px');
|
||||
ajaxWrapper.css('margin', '0px');
|
||||
|
||||
});
|
||||
|
||||
// second (backup) lightbox behavior for add field
|
||||
jQuery('#addfields2').click(function() {
|
||||
var add_field_popup = jQuery('#add_field_popup');
|
||||
|
||||
add_field_popup.css("position","absolute");
|
||||
add_field_popup.css('width', '700px');
|
||||
add_field_popup.css('height', '500px');
|
||||
add_field_popup.css('z-index', '10000px');
|
||||
|
||||
add_field_popup.css('top', '-100px');
|
||||
add_field_popup.css('left', '150px');
|
||||
|
||||
// add_field_popup.css("top", ((jQuery(window).height() - add_field_popup.outerHeight()) / 2) +
|
||||
// jQuery(window).scrollTop() + "px");
|
||||
// add_field_popup.css("left", ((jQuery(window).width() - add_field_popup.outerWidth()) / 2) +
|
||||
// jQuery(window).scrollLeft() + "px");
|
||||
if(jQuery('#add_field_popup').css('display') == 'block') {
|
||||
jQuery('#add_field_popup').css('display', 'none');
|
||||
}
|
||||
else {
|
||||
jQuery('#add_field_popup').css('display', 'block');
|
||||
}
|
||||
});
|
||||
|
||||
// this manages the "V" button
|
||||
jQuery('.editor_addon_wrapper img').click(function(e){
|
||||
if (jQuery(this).parent().find('.editor_addon_dropdown').css('visibility') == 'hidden') {
|
||||
// Close others possibly opened
|
||||
wpv_hide_top_groups(jQuery(this).parent());
|
||||
jQuery('.editor_addon_dropdown').css('visibility', 'hidden').hide().css('display', 'inline');
|
||||
jQuery(this).parent().find('.editor_addon_dropdown').css('visibility', 'visible').show().css('display', 'inline');
|
||||
jQuery(document.body).bind('click',function(e){
|
||||
if (jQuery(e.target).parents('.editor_addon_wrapper').length < 1) {
|
||||
jQuery('.editor_addon_dropdown').css('visibility', 'hidden').hide().css('display', 'inline');
|
||||
jQuery(this).unbind(e);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
jQuery('.editor_addon_dropdown').css('visibility', 'hidden').hide().css('display', 'inline');
|
||||
}
|
||||
// Bind close on iFrame click (it's loaded now)
|
||||
jQuery('#content_ifr').contents().bind('click', function(e) {
|
||||
jQuery('.editor_addon_dropdown').css('visibility', 'hidden').hide().css('display', 'inline');
|
||||
});
|
||||
// Bind Escape
|
||||
jQuery(document).bind('keyup', function(e) {
|
||||
if (e.keyCode == 27) {
|
||||
jQuery('.editor_addon_dropdown').css('visibility', 'hidden').hide().css('display', 'inline');
|
||||
jQuery(this).unbind(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
jQuery('.editor_addon_wrapper .item, .editor_addon_dropdown .close').click(function(e){
|
||||
jQuery('.editor_addon_dropdown').css('visibility', 'hidden').hide().css('display', 'inline');
|
||||
});
|
||||
// Resize dropdowns if necessary (in #media-buttons)
|
||||
jQuery('#media-buttons .editor_addon_dropdown, #wp-content-media-buttons .editor_addon_dropdown').each(function(){
|
||||
var width = jQuery(this).width();
|
||||
var height = jQuery(this).height();
|
||||
var screenHeight = jQuery(window).height();
|
||||
var offset = jQuery(this).offset();
|
||||
|
||||
if (offset.top+height > screenHeight) {
|
||||
var resizedHeight = Math.round(screenHeight-offset.top-20);
|
||||
if (resizedHeight < 200) {
|
||||
resizedHeight = 200;
|
||||
}
|
||||
jQuery(this).height(resizedHeight);
|
||||
jQuery(this).css('height', resizedHeight+'px');
|
||||
var scrollHeight = Math.round(resizedHeight-jQuery(this).find('.direct-links').height()-50);
|
||||
jQuery(this).find('.scroll').css('height', scrollHeight+'px');
|
||||
} else {
|
||||
jQuery(this).find('.direct-links').hide();
|
||||
jQuery(this).find('.editor-addon-link-to-top').hide();
|
||||
}
|
||||
|
||||
// make sure the popup is not to wide.
|
||||
var screenWidth = jQuery(window).width();
|
||||
if (offset.left + width > screenWidth) {
|
||||
jQuery(this).css('width', screenWidth - offset.left - 20 + 'px');
|
||||
}
|
||||
|
||||
|
||||
// jQuery(this).find('.scroll').jScrollPane();
|
||||
});
|
||||
// For hidden in Meta HTML set scroll when visible
|
||||
jQuery('#wpv_layout_meta_html_admin_show a, #wpv_filter_meta_html_admin_show a').click(function(){
|
||||
jQuery(this).parent().parent().find('.editor_addon_dropdown').each(function(){
|
||||
var scrollDiv = jQuery(this).find('.scroll');
|
||||
var divWidth = 400;
|
||||
var divHeight = 250;
|
||||
jQuery(this).width(divWidth).css('width', divWidth+'px');
|
||||
scrollDiv.width(Math.round(divWidth-40)).css('width', (Math.round(divWidth-40))+'px');
|
||||
jQuery(this).height(divHeight).css('height', divHeight+'px');
|
||||
var scrollHeight = Math.round(divHeight-jQuery(this).find('.direct-links').height()-50);
|
||||
scrollDiv.height(scrollHeight).css('height', scrollHeight+'px');
|
||||
// scrollDiv.jScrollPane();
|
||||
if (jQuery(this).find('.jspPane').height() < scrollDiv.height()) {
|
||||
jQuery(this).find('.direct-links').hide();
|
||||
scrollDiv.height(Math.round(divHeight-50)).css('height', (Math.round(divHeight-50))+'px');
|
||||
}
|
||||
});
|
||||
});
|
||||
// Set Meta HTML dropdown to insert there
|
||||
window.wpcfInsertMetaHTML = false;
|
||||
jQuery('#wpv_layout_meta_html_admin_edit .item, #wpv_filter_meta_html_admin_edit .item').click(function(){
|
||||
window.wpcfInsertMetaHTML = jQuery(this).parents('.editor_addon_wrapper').parent().find('textarea').attr('id');
|
||||
});
|
||||
// Direct links
|
||||
jQuery('.editor-addon-top-link').bind('click', function(){
|
||||
// var api = jQuery(this).parents('.editor_addon_dropdown').find('.scroll').data('jsp');
|
||||
// if (typeof api != 'undefined') {
|
||||
// var wpcfScrollToElement = jQuery(this).attr('id')+'-target';
|
||||
// api.scrollToElement(jQuery('#'+wpcfScrollToElement).parent(), true, true);
|
||||
// }
|
||||
// get position of elements
|
||||
var positionNested = jQuery('#'+jQuery(this).attr('id')+'-target').offset();
|
||||
var positionParent = jQuery('#'+jQuery(this).attr('id')+'-target').parent().parent().offset();
|
||||
if (positionParent.top > positionNested.top) {
|
||||
var scrollTo = positionParent.top - positionNested.top;
|
||||
} else {
|
||||
var scrollTo = positionNested.top - positionParent.top;
|
||||
}
|
||||
jQuery(this).parents('.editor_addon_dropdown').find('.scroll').animate({scrollTop:Math.round(scrollTo)}, 'fast');
|
||||
return false;
|
||||
});
|
||||
// jQuery('.editor-addon-link-to-top').click(function(){
|
||||
// var api = jQuery(this).parents('.editor_addon_dropdown').find('.scroll').data('jsp');
|
||||
// var scrollToElement = jQuery(this).parents('.editor_addon_dropdown').find('.group');
|
||||
// api.scrollToElement(scrollToElement, true, true);
|
||||
// return false;
|
||||
// });
|
||||
});
|
||||
|
||||
var keyStr = "ABCDEFGHIJKLMNOP" +
|
||||
"QRSTUVWXYZabcdef" +
|
||||
"ghijklmnopqrstuv" +
|
||||
"wxyz0123456789+/" +
|
||||
"=";
|
||||
|
||||
function editor_decode64(input) {
|
||||
var output = "";
|
||||
var chr1, chr2, chr3 = "";
|
||||
var enc1, enc2, enc3, enc4 = "";
|
||||
var i = 0;
|
||||
|
||||
// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
|
||||
var base64test = /[^A-Za-z0-9\+\/\=]/g;
|
||||
if (base64test.exec(input)) {
|
||||
alert("There were invalid base64 characters in the input text.\n" +
|
||||
"Valid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\n" +
|
||||
"Expect errors in decoding.");
|
||||
}
|
||||
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
|
||||
|
||||
do {
|
||||
enc1 = keyStr.indexOf(input.charAt(i++));
|
||||
enc2 = keyStr.indexOf(input.charAt(i++));
|
||||
enc3 = keyStr.indexOf(input.charAt(i++));
|
||||
enc4 = keyStr.indexOf(input.charAt(i++));
|
||||
|
||||
chr1 = (enc1 << 2) | (enc2 >> 4);
|
||||
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
||||
chr3 = ((enc3 & 3) << 6) | enc4;
|
||||
|
||||
output = output + String.fromCharCode(chr1);
|
||||
|
||||
if (enc3 != 64) {
|
||||
output = output + String.fromCharCode(chr2);
|
||||
}
|
||||
if (enc4 != 64) {
|
||||
output = output + String.fromCharCode(chr3);
|
||||
}
|
||||
|
||||
chr1 = chr2 = chr3 = "";
|
||||
enc1 = enc2 = enc3 = enc4 = "";
|
||||
|
||||
} while (i < input.length);
|
||||
|
||||
return unescape(output);
|
||||
}
|
||||
|
||||
function insert_b64_shortcode_to_editor(b64_shortcode, text_area) {
|
||||
var shortcode = editor_decode64(b64_shortcode);
|
||||
if(shortcode.indexOf('[types') == 0 && shortcode.indexOf('[/types') === false) {
|
||||
shortcode += '[/types]';
|
||||
}
|
||||
|
||||
if (text_area == 'textarea#content') {
|
||||
// the main editor
|
||||
if (window.parent.jQuery('textarea#content:visible').length) {
|
||||
// HTML editor
|
||||
window.parent.jQuery('textarea#content').insertAtCaret(shortcode);
|
||||
} else {
|
||||
// Visual editor
|
||||
window.parent.tinyMCE.activeEditor.execCommand('mceInsertContent', false, shortcode);
|
||||
}
|
||||
} else {
|
||||
// the other editor
|
||||
if (window.parent.jQuery('textarea#'+text_area+':visible').length) {
|
||||
// HTML editor
|
||||
window.parent.jQuery('textarea#'+text_area).insertAtCaret(shortcode);
|
||||
} else {
|
||||
// Visual editor
|
||||
window.parent.tinyMCE.execCommand('mceFocus', false, text_area);
|
||||
window.parent.tinyMCE.activeEditor.execCommand('mceInsertContent', false, shortcode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filtering elements from search boxes with JS
|
||||
*/
|
||||
function wpv_on_search_filter(el) {
|
||||
// get search text
|
||||
var searchText = jQuery(el).val();
|
||||
|
||||
// get parent on DOM to find items and hide/show Search
|
||||
var parent = el.parentNode.parentNode;
|
||||
var searchItems = jQuery(parent).find('.group .item');
|
||||
|
||||
jQuery(parent).find('.search_clear').css('display', (searchText == '') ? 'none' : 'inline');
|
||||
|
||||
// iterate items and search
|
||||
jQuery(searchItems).each(function() {
|
||||
if(searchText == '' || jQuery(this).text().search(new RegExp(searchText, 'i')) > -1) {
|
||||
// alert(jQuery(this).text());
|
||||
jQuery(this).css('display', 'inline');
|
||||
}
|
||||
else {
|
||||
jQuery(this).css('display', 'none');
|
||||
}
|
||||
});
|
||||
|
||||
// iterate group titles and check if they have items (otherwise hide them)
|
||||
|
||||
wpv_hide_top_groups(parent);
|
||||
}
|
||||
|
||||
function wpv_hide_top_groups(parent) {
|
||||
var groupTitles = jQuery(parent).find('.group-title');
|
||||
jQuery(groupTitles).each(function() {
|
||||
var parentOfGroup = jQuery(this).parent();
|
||||
// by default we assume that there are no children to show
|
||||
var visibleGroup = false;
|
||||
jQuery(parentOfGroup).find('.item').each(function() {
|
||||
if(jQuery(this).css('display') == 'inline') {
|
||||
visibleGroup = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if(!visibleGroup) {
|
||||
jQuery(this).css('display', 'none');
|
||||
} else {
|
||||
jQuery(this).css('display', 'block');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// clear search input
|
||||
function wpv_search_clear(el) {
|
||||
var parent = el.parentNode.parentNode;
|
||||
var searchbox = jQuery(parent).find('.search_field');
|
||||
searchbox.val('');
|
||||
wpv_on_search_filter(searchbox[0]);
|
||||
}
|
||||
@ -1,78 +0,0 @@
|
||||
/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
|
||||
* Licensed under the MIT License (LICENSE.txt).
|
||||
*
|
||||
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
|
||||
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
|
||||
* Thanks to: Seamus Leahy for adding deltaX and deltaY
|
||||
*
|
||||
* Version: 3.0.4
|
||||
*
|
||||
* Requires: 1.2.2+
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
|
||||
var types = ['DOMMouseScroll', 'mousewheel'];
|
||||
|
||||
$.event.special.mousewheel = {
|
||||
setup: function() {
|
||||
if ( this.addEventListener ) {
|
||||
for ( var i=types.length; i; ) {
|
||||
this.addEventListener( types[--i], handler, false );
|
||||
}
|
||||
} else {
|
||||
this.onmousewheel = handler;
|
||||
}
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
if ( this.removeEventListener ) {
|
||||
for ( var i=types.length; i; ) {
|
||||
this.removeEventListener( types[--i], handler, false );
|
||||
}
|
||||
} else {
|
||||
this.onmousewheel = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.extend({
|
||||
mousewheel: function(fn) {
|
||||
return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
|
||||
},
|
||||
|
||||
unmousewheel: function(fn) {
|
||||
return this.unbind("mousewheel", fn);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function handler(event) {
|
||||
var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
|
||||
event = $.event.fix(orgEvent);
|
||||
event.type = "mousewheel";
|
||||
|
||||
// Old school scrollwheel delta
|
||||
if ( event.wheelDelta ) { delta = event.wheelDelta/120; }
|
||||
if ( event.detail ) { delta = -event.detail/3; }
|
||||
|
||||
// New school multidimensional scroll (touchpads) deltas
|
||||
deltaY = delta;
|
||||
|
||||
// Gecko
|
||||
if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
|
||||
deltaY = 0;
|
||||
deltaX = -1*delta;
|
||||
}
|
||||
|
||||
// Webkit
|
||||
if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
|
||||
if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }
|
||||
|
||||
// Add event and delta to the front of the arguments
|
||||
args.unshift(event, delta, deltaX, deltaY);
|
||||
|
||||
return $.event.handle.apply(this, args);
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
@ -1,11 +0,0 @@
|
||||
/*
|
||||
* jScrollPane - v2.0.0beta11 - 2011-07-04
|
||||
* http://jscrollpane.kelvinluck.com/
|
||||
*
|
||||
* Copyright (c) 2010 Kelvin Luck
|
||||
* Dual licensed under the MIT and GPL licenses.
|
||||
*/
|
||||
(function(b,a,c){b.fn.jScrollPane=function(e){function d(D,O){var az,Q=this,Y,ak,v,am,T,Z,y,q,aA,aF,av,i,I,h,j,aa,U,aq,X,t,A,ar,af,an,G,l,au,ay,x,aw,aI,f,L,aj=true,P=true,aH=false,k=false,ap=D.clone(false,false).empty(),ac=b.fn.mwheelIntent?"mwheelIntent.jsp":"mousewheel.jsp";aI=D.css("paddingTop")+" "+D.css("paddingRight")+" "+D.css("paddingBottom")+" "+D.css("paddingLeft");f=(parseInt(D.css("paddingLeft"),10)||0)+(parseInt(D.css("paddingRight"),10)||0);function at(aR){var aM,aO,aN,aK,aJ,aQ,aP=false,aL=false;az=aR;if(Y===c){aJ=D.scrollTop();aQ=D.scrollLeft();D.css({overflow:"hidden",padding:0});ak=D.innerWidth()+f;v=D.innerHeight();D.width(ak);Y=b('<div class="jspPane" />').css("padding",aI).append(D.children());am=b('<div class="jspContainer" />').css({width:ak+"px",height:v+"px"}).append(Y).appendTo(D)}else{D.css("width","");aP=az.stickToBottom&&K();aL=az.stickToRight&&B();aK=D.innerWidth()+f!=ak||D.outerHeight()!=v;if(aK){ak=D.innerWidth()+f;v=D.innerHeight();am.css({width:ak+"px",height:v+"px"})}if(!aK&&L==T&&Y.outerHeight()==Z){D.width(ak);return}L=T;Y.css("width","");D.width(ak);am.find(">.jspVerticalBar,>.jspHorizontalBar").remove().end()}Y.css("overflow","auto");if(aR.contentWidth){T=aR.contentWidth}else{T=Y[0].scrollWidth}Z=Y[0].scrollHeight;Y.css("overflow","");y=T/ak;q=Z/v;aA=q>1;aF=y>1;if(!(aF||aA)){D.removeClass("jspScrollable");Y.css({top:0,width:am.width()-f});n();E();R();w();ai()}else{D.addClass("jspScrollable");aM=az.maintainPosition&&(I||aa);if(aM){aO=aD();aN=aB()}aG();z();F();if(aM){N(aL?(T-ak):aO,false);M(aP?(Z-v):aN,false)}J();ag();ao();if(az.enableKeyboardNavigation){S()}if(az.clickOnTrack){p()}C();if(az.hijackInternalLinks){m()}}if(az.autoReinitialise&&!aw){aw=setInterval(function(){at(az)},az.autoReinitialiseDelay)}else{if(!az.autoReinitialise&&aw){clearInterval(aw)}}aJ&&D.scrollTop(0)&&M(aJ,false);aQ&&D.scrollLeft(0)&&N(aQ,false);D.trigger("jsp-initialised",[aF||aA])}function aG(){if(aA){am.append(b('<div class="jspVerticalBar" />').append(b('<div class="jspCap jspCapTop" />'),b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragTop" />'),b('<div class="jspDragBottom" />'))),b('<div class="jspCap jspCapBottom" />')));U=am.find(">.jspVerticalBar");aq=U.find(">.jspTrack");av=aq.find(">.jspDrag");if(az.showArrows){ar=b('<a class="jspArrow jspArrowUp" />').bind("mousedown.jsp",aE(0,-1)).bind("click.jsp",aC);af=b('<a class="jspArrow jspArrowDown" />').bind("mousedown.jsp",aE(0,1)).bind("click.jsp",aC);if(az.arrowScrollOnHover){ar.bind("mouseover.jsp",aE(0,-1,ar));af.bind("mouseover.jsp",aE(0,1,af))}al(aq,az.verticalArrowPositions,ar,af)}t=v;am.find(">.jspVerticalBar>.jspCap:visible,>.jspVerticalBar>.jspArrow").each(function(){t-=b(this).outerHeight()});av.hover(function(){av.addClass("jspHover")},function(){av.removeClass("jspHover")}).bind("mousedown.jsp",function(aJ){b("html").bind("dragstart.jsp selectstart.jsp",aC);av.addClass("jspActive");var s=aJ.pageY-av.position().top;b("html").bind("mousemove.jsp",function(aK){V(aK.pageY-s,false)}).bind("mouseup.jsp mouseleave.jsp",ax);return false});o()}}function o(){aq.height(t+"px");I=0;X=az.verticalGutter+aq.outerWidth();Y.width(ak-X-f);try{if(U.position().left===0){Y.css("margin-left",X+"px")}}catch(s){}}function z(){if(aF){am.append(b('<div class="jspHorizontalBar" />').append(b('<div class="jspCap jspCapLeft" />'),b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragLeft" />'),b('<div class="jspDragRight" />'))),b('<div class="jspCap jspCapRight" />')));an=am.find(">.jspHorizontalBar");G=an.find(">.jspTrack");h=G.find(">.jspDrag");if(az.showArrows){ay=b('<a class="jspArrow jspArrowLeft" />').bind("mousedown.jsp",aE(-1,0)).bind("click.jsp",aC);x=b('<a class="jspArrow jspArrowRight" />').bind("mousedown.jsp",aE(1,0)).bind("click.jsp",aC);
|
||||
if(az.arrowScrollOnHover){ay.bind("mouseover.jsp",aE(-1,0,ay));x.bind("mouseover.jsp",aE(1,0,x))}al(G,az.horizontalArrowPositions,ay,x)}h.hover(function(){h.addClass("jspHover")},function(){h.removeClass("jspHover")}).bind("mousedown.jsp",function(aJ){b("html").bind("dragstart.jsp selectstart.jsp",aC);h.addClass("jspActive");var s=aJ.pageX-h.position().left;b("html").bind("mousemove.jsp",function(aK){W(aK.pageX-s,false)}).bind("mouseup.jsp mouseleave.jsp",ax);return false});l=am.innerWidth();ah()}}function ah(){am.find(">.jspHorizontalBar>.jspCap:visible,>.jspHorizontalBar>.jspArrow").each(function(){l-=b(this).outerWidth()});G.width(l+"px");aa=0}function F(){if(aF&&aA){var aJ=G.outerHeight(),s=aq.outerWidth();t-=aJ;b(an).find(">.jspCap:visible,>.jspArrow").each(function(){l+=b(this).outerWidth()});l-=s;v-=s;ak-=aJ;G.parent().append(b('<div class="jspCorner" />').css("width",aJ+"px"));o();ah()}if(aF){Y.width((am.outerWidth()-f)+"px")}Z=Y.outerHeight();q=Z/v;if(aF){au=Math.ceil(1/y*l);if(au>az.horizontalDragMaxWidth){au=az.horizontalDragMaxWidth}else{if(au<az.horizontalDragMinWidth){au=az.horizontalDragMinWidth}}h.width(au+"px");j=l-au;ae(aa)}if(aA){A=Math.ceil(1/q*t);if(A>az.verticalDragMaxHeight){A=az.verticalDragMaxHeight}else{if(A<az.verticalDragMinHeight){A=az.verticalDragMinHeight}}av.height(A+"px");i=t-A;ad(I)}}function al(aK,aM,aJ,s){var aO="before",aL="after",aN;if(aM=="os"){aM=/Mac/.test(navigator.platform)?"after":"split"}if(aM==aO){aL=aM}else{if(aM==aL){aO=aM;aN=aJ;aJ=s;s=aN}}aK[aO](aJ)[aL](s)}function aE(aJ,s,aK){return function(){H(aJ,s,this,aK);this.blur();return false}}function H(aM,aL,aP,aO){aP=b(aP).addClass("jspActive");var aN,aK,aJ=true,s=function(){if(aM!==0){Q.scrollByX(aM*az.arrowButtonSpeed)}if(aL!==0){Q.scrollByY(aL*az.arrowButtonSpeed)}aK=setTimeout(s,aJ?az.initialDelay:az.arrowRepeatFreq);aJ=false};s();aN=aO?"mouseout.jsp":"mouseup.jsp";aO=aO||b("html");aO.bind(aN,function(){aP.removeClass("jspActive");aK&&clearTimeout(aK);aK=null;aO.unbind(aN)})}function p(){w();if(aA){aq.bind("mousedown.jsp",function(aO){if(aO.originalTarget===c||aO.originalTarget==aO.currentTarget){var aM=b(this),aP=aM.offset(),aN=aO.pageY-aP.top-I,aK,aJ=true,s=function(){var aS=aM.offset(),aT=aO.pageY-aS.top-A/2,aQ=v*az.scrollPagePercent,aR=i*aQ/(Z-v);if(aN<0){if(I-aR>aT){Q.scrollByY(-aQ)}else{V(aT)}}else{if(aN>0){if(I+aR<aT){Q.scrollByY(aQ)}else{V(aT)}}else{aL();return}}aK=setTimeout(s,aJ?az.initialDelay:az.trackClickRepeatFreq);aJ=false},aL=function(){aK&&clearTimeout(aK);aK=null;b(document).unbind("mouseup.jsp",aL)};s();b(document).bind("mouseup.jsp",aL);return false}})}if(aF){G.bind("mousedown.jsp",function(aO){if(aO.originalTarget===c||aO.originalTarget==aO.currentTarget){var aM=b(this),aP=aM.offset(),aN=aO.pageX-aP.left-aa,aK,aJ=true,s=function(){var aS=aM.offset(),aT=aO.pageX-aS.left-au/2,aQ=ak*az.scrollPagePercent,aR=j*aQ/(T-ak);if(aN<0){if(aa-aR>aT){Q.scrollByX(-aQ)}else{W(aT)}}else{if(aN>0){if(aa+aR<aT){Q.scrollByX(aQ)}else{W(aT)}}else{aL();return}}aK=setTimeout(s,aJ?az.initialDelay:az.trackClickRepeatFreq);aJ=false},aL=function(){aK&&clearTimeout(aK);aK=null;b(document).unbind("mouseup.jsp",aL)};s();b(document).bind("mouseup.jsp",aL);return false}})}}function w(){if(G){G.unbind("mousedown.jsp")}if(aq){aq.unbind("mousedown.jsp")}}function ax(){b("html").unbind("dragstart.jsp selectstart.jsp mousemove.jsp mouseup.jsp mouseleave.jsp");if(av){av.removeClass("jspActive")}if(h){h.removeClass("jspActive")}}function V(s,aJ){if(!aA){return}if(s<0){s=0}else{if(s>i){s=i}}if(aJ===c){aJ=az.animateScroll}if(aJ){Q.animate(av,"top",s,ad)}else{av.css("top",s);ad(s)}}function ad(aJ){if(aJ===c){aJ=av.position().top}am.scrollTop(0);I=aJ;var aM=I===0,aK=I==i,aL=aJ/i,s=-aL*(Z-v);if(aj!=aM||aH!=aK){aj=aM;aH=aK;D.trigger("jsp-arrow-change",[aj,aH,P,k])}u(aM,aK);Y.css("top",s);D.trigger("jsp-scroll-y",[-s,aM,aK]).trigger("scroll")}function W(aJ,s){if(!aF){return}if(aJ<0){aJ=0}else{if(aJ>j){aJ=j}}if(s===c){s=az.animateScroll}if(s){Q.animate(h,"left",aJ,ae)
|
||||
}else{h.css("left",aJ);ae(aJ)}}function ae(aJ){if(aJ===c){aJ=h.position().left}am.scrollTop(0);aa=aJ;var aM=aa===0,aL=aa==j,aK=aJ/j,s=-aK*(T-ak);if(P!=aM||k!=aL){P=aM;k=aL;D.trigger("jsp-arrow-change",[aj,aH,P,k])}r(aM,aL);Y.css("left",s);D.trigger("jsp-scroll-x",[-s,aM,aL]).trigger("scroll")}function u(aJ,s){if(az.showArrows){ar[aJ?"addClass":"removeClass"]("jspDisabled");af[s?"addClass":"removeClass"]("jspDisabled")}}function r(aJ,s){if(az.showArrows){ay[aJ?"addClass":"removeClass"]("jspDisabled");x[s?"addClass":"removeClass"]("jspDisabled")}}function M(s,aJ){var aK=s/(Z-v);V(aK*i,aJ)}function N(aJ,s){var aK=aJ/(T-ak);W(aK*j,s)}function ab(aW,aR,aK){var aO,aL,aM,s=0,aV=0,aJ,aQ,aP,aT,aS,aU;try{aO=b(aW)}catch(aN){return}aL=aO.outerHeight();aM=aO.outerWidth();am.scrollTop(0);am.scrollLeft(0);while(!aO.is(".jspPane")){s+=aO.position().top;aV+=aO.position().left;aO=aO.offsetParent();if(/^body|html$/i.test(aO[0].nodeName)){return}}aJ=aB();aP=aJ+v;if(s<aJ||aR){aS=s-az.verticalGutter}else{if(s+aL>aP){aS=s-v+aL+az.verticalGutter}}if(aS){M(aS,aK)}aQ=aD();aT=aQ+ak;if(aV<aQ||aR){aU=aV-az.horizontalGutter}else{if(aV+aM>aT){aU=aV-ak+aM+az.horizontalGutter}}if(aU){N(aU,aK)}}function aD(){return -Y.position().left}function aB(){return -Y.position().top}function K(){var s=Z-v;return(s>20)&&(s-aB()<10)}function B(){var s=T-ak;return(s>20)&&(s-aD()<10)}function ag(){am.unbind(ac).bind(ac,function(aM,aN,aL,aJ){var aK=aa,s=I;Q.scrollBy(aL*az.mouseWheelSpeed,-aJ*az.mouseWheelSpeed,false);return aK==aa&&s==I})}function n(){am.unbind(ac)}function aC(){return false}function J(){Y.find(":input,a").unbind("focus.jsp").bind("focus.jsp",function(s){ab(s.target,false)})}function E(){Y.find(":input,a").unbind("focus.jsp")}function S(){var s,aJ,aL=[];aF&&aL.push(an[0]);aA&&aL.push(U[0]);Y.focus(function(){D.focus()});D.attr("tabindex",0).unbind("keydown.jsp keypress.jsp").bind("keydown.jsp",function(aO){if(aO.target!==this&&!(aL.length&&b(aO.target).closest(aL).length)){return}var aN=aa,aM=I;switch(aO.keyCode){case 40:case 38:case 34:case 32:case 33:case 39:case 37:s=aO.keyCode;aK();break;case 35:M(Z-v);s=null;break;case 36:M(0);s=null;break}aJ=aO.keyCode==s&&aN!=aa||aM!=I;return !aJ}).bind("keypress.jsp",function(aM){if(aM.keyCode==s){aK()}return !aJ});if(az.hideFocus){D.css("outline","none");if("hideFocus" in am[0]){D.attr("hideFocus",true)}}else{D.css("outline","");if("hideFocus" in am[0]){D.attr("hideFocus",false)}}function aK(){var aN=aa,aM=I;switch(s){case 40:Q.scrollByY(az.keyboardSpeed,false);break;case 38:Q.scrollByY(-az.keyboardSpeed,false);break;case 34:case 32:Q.scrollByY(v*az.scrollPagePercent,false);break;case 33:Q.scrollByY(-v*az.scrollPagePercent,false);break;case 39:Q.scrollByX(az.keyboardSpeed,false);break;case 37:Q.scrollByX(-az.keyboardSpeed,false);break}aJ=aN!=aa||aM!=I;return aJ}}function R(){D.attr("tabindex","-1").removeAttr("tabindex").unbind("keydown.jsp keypress.jsp")}function C(){if(location.hash&&location.hash.length>1){var aL,aJ,aK=escape(location.hash);try{aL=b(aK)}catch(s){return}if(aL.length&&Y.find(aK)){if(am.scrollTop()===0){aJ=setInterval(function(){if(am.scrollTop()>0){ab(aK,true);b(document).scrollTop(am.position().top);clearInterval(aJ)}},50)}else{ab(aK,true);b(document).scrollTop(am.position().top)}}}}function ai(){b("a.jspHijack").unbind("click.jsp-hijack").removeClass("jspHijack")}function m(){ai();b("a[href^=#]").addClass("jspHijack").bind("click.jsp-hijack",function(){var s=this.href.split("#"),aJ;if(s.length>1){aJ=s[1];if(aJ.length>0&&Y.find("#"+aJ).length>0){ab("#"+aJ,true);return false}}})}function ao(){var aK,aJ,aM,aL,aN,s=false;am.unbind("touchstart.jsp touchmove.jsp touchend.jsp click.jsp-touchclick").bind("touchstart.jsp",function(aO){var aP=aO.originalEvent.touches[0];aK=aD();aJ=aB();aM=aP.pageX;aL=aP.pageY;aN=false;s=true}).bind("touchmove.jsp",function(aR){if(!s){return}var aQ=aR.originalEvent.touches[0],aP=aa,aO=I;Q.scrollTo(aK+aM-aQ.pageX,aJ+aL-aQ.pageY);aN=aN||Math.abs(aM-aQ.pageX)>5||Math.abs(aL-aQ.pageY)>5;
|
||||
return aP==aa&&aO==I}).bind("touchend.jsp",function(aO){s=false}).bind("click.jsp-touchclick",function(aO){if(aN){aN=false;return false}})}function g(){var s=aB(),aJ=aD();D.removeClass("jspScrollable").unbind(".jsp");D.replaceWith(ap.append(Y.children()));ap.scrollTop(s);ap.scrollLeft(aJ)}b.extend(Q,{reinitialise:function(aJ){aJ=b.extend({},az,aJ);at(aJ)},scrollToElement:function(aK,aJ,s){ab(aK,aJ,s)},scrollTo:function(aK,s,aJ){N(aK,aJ);M(s,aJ)},scrollToX:function(aJ,s){N(aJ,s)},scrollToY:function(s,aJ){M(s,aJ)},scrollToPercentX:function(aJ,s){N(aJ*(T-ak),s)},scrollToPercentY:function(aJ,s){M(aJ*(Z-v),s)},scrollBy:function(aJ,s,aK){Q.scrollByX(aJ,aK);Q.scrollByY(s,aK)},scrollByX:function(s,aK){var aJ=aD()+Math[s<0?"floor":"ceil"](s),aL=aJ/(T-ak);W(aL*j,aK)},scrollByY:function(s,aK){var aJ=aB()+Math[s<0?"floor":"ceil"](s),aL=aJ/(Z-v);V(aL*i,aK)},positionDragX:function(s,aJ){W(s,aJ)},positionDragY:function(aJ,s){V(aJ,s)},animate:function(aJ,aM,s,aL){var aK={};aK[aM]=s;aJ.animate(aK,{duration:az.animateDuration,easing:az.animateEase,queue:false,step:aL})},getContentPositionX:function(){return aD()},getContentPositionY:function(){return aB()},getContentWidth:function(){return T},getContentHeight:function(){return Z},getPercentScrolledX:function(){return aD()/(T-ak)},getPercentScrolledY:function(){return aB()/(Z-v)},getIsScrollableH:function(){return aF},getIsScrollableV:function(){return aA},getContentPane:function(){return Y},scrollToBottom:function(s){V(i,s)},hijackInternalLinks:function(){m()},destroy:function(){g()}});at(O)}e=b.extend({},b.fn.jScrollPane.defaults,e);b.each(["mouseWheelSpeed","arrowButtonSpeed","trackClickSpeed","keyboardSpeed"],function(){e[this]=e[this]||e.speed});return this.each(function(){var f=b(this),g=f.data("jsp");if(g){g.reinitialise(e)}else{g=new d(f,e);f.data("jsp",g)}})};b.fn.jScrollPane.defaults={showArrows:false,maintainPosition:true,stickToBottom:false,stickToRight:false,clickOnTrack:true,autoReinitialise:false,autoReinitialiseDelay:500,verticalDragMinHeight:0,verticalDragMaxHeight:99999,horizontalDragMinWidth:0,horizontalDragMaxWidth:99999,contentWidth:c,animateScroll:false,animateDuration:300,animateEase:"linear",hijackInternalLinks:false,verticalGutter:4,horizontalGutter:4,mouseWheelSpeed:0,arrowButtonSpeed:0,arrowRepeatFreq:50,arrowScrollOnHover:false,trackClickSpeed:0,trackClickRepeatFreq:70,verticalArrowPositions:"split",horizontalArrowPositions:"split",enableKeyboardNavigation:true,hideFocus:false,keyboardSpeed:0,initialDelay:300,speed:30,scrollPagePercent:0.8}})(jQuery,this);
|
||||
@ -1,308 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Modified standalone version of the WPLogger class for internal purposes.
|
||||
*
|
||||
*
|
||||
*
|
||||
Plugin Name: Wordpress Logger
|
||||
Plugin URI: http://www.turingtarpit.com/2009/05/wordpress-logger-a-plugin-to-display-php-log-messages-in-safari-and-firefox/
|
||||
Description: Displays log messages in the browser console in Safari, Firefox and Opera. Useful for plugin and theme developers to debug PHP code.
|
||||
Version: 0.3
|
||||
Author: Chandima Cumaranatunge
|
||||
Author URI: http://www.turingtarpit.com
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Code to force the plugin to load before others adapted from the
|
||||
WordPress FirePHP plugin developed by Ivan Weiller.
|
||||
http://inchoo.net/wordpress/wordpress-firephp-plugin/
|
||||
|
||||
Requirements:
|
||||
* PHP 5+
|
||||
* Wordpress 2.5+
|
||||
* JQuery 1.2.6
|
||||
* Firefox browser with firePHP plugin activated OR
|
||||
Safari browser with Error Console turned on
|
||||
|
||||
Usage:
|
||||
$wplogger->log( mixed php_expression [, const message_type] )
|
||||
|
||||
message_type can be: WPLOG_ERR. WPLOG_WARNING, WPLOG_INFO, WPLOG_DEBUG
|
||||
|
||||
Example:
|
||||
if ($wplogger) $wplogger->log( get_option('active_plugins') );
|
||||
|
||||
Output ( from the browser console ):
|
||||
[Information: from line xxx in file somefile.php] array (
|
||||
0 => 'wplogger/wplogger.php',
|
||||
1 => '12seconds-widget/12seconds-widget.php',
|
||||
2 => 'get-the-image/get-the-image.php',
|
||||
)
|
||||
*/
|
||||
|
||||
/* Types of log messages */
|
||||
define( 'WPLOG_ERR', 'error' ); /* Error conditions */
|
||||
define( 'WPLOG_WARNING', 'warn' ); /* Warning conditions */
|
||||
define( 'WPLOG_INFO', 'info' ); /* Informational */
|
||||
define( 'WPLOG_DEBUG', 'debug' ); /* Debug-level messages */
|
||||
define( 'WPLOG_OFF', '' ); /* NO debug enabled */
|
||||
|
||||
/* New Wordpress Logger instance */
|
||||
global $wplogger;
|
||||
$wplogger = new WPV_WPLogger();
|
||||
|
||||
function wplogger( $message = '', $msgType = null )
|
||||
{
|
||||
global $wplogger;
|
||||
$wplogger->log( $message, $msgType );
|
||||
}
|
||||
|
||||
/* Register function to add logging script */
|
||||
add_action( 'wp_footer', array($wplogger, 'flushLogMessages') ); // log scripts
|
||||
/* Ensure logging works in admin pages as well */
|
||||
add_action ('admin_footer', array ($wplogger, 'flushLogMessages'));
|
||||
|
||||
/**
|
||||
* WPV_WPLogger Class
|
||||
* renamed for compatibility reasons
|
||||
*/
|
||||
class WPV_WPLogger
|
||||
{
|
||||
|
||||
/**
|
||||
* String holding the buffered output.
|
||||
*/
|
||||
var $_buffer = array();
|
||||
|
||||
/**
|
||||
* The default priority to use when logging an event.
|
||||
*/
|
||||
var $_defaultMsgType = WPLOG_INFO;
|
||||
|
||||
/**
|
||||
* Long descriptions of debug message types
|
||||
*/
|
||||
var $_msgTypeLong = array(
|
||||
WPLOG_ERR => 'error',
|
||||
WPLOG_WARNING => 'warn',
|
||||
WPLOG_INFO => 'info',
|
||||
WPLOG_DEBUG => 'debug'
|
||||
);
|
||||
|
||||
var $_msgStatusPriority = array(
|
||||
WPLOG_ERR => '50',
|
||||
WPLOG_WARNING => '40',
|
||||
WPLOG_INFO => '30',
|
||||
WPLOG_DEBUG => '20',
|
||||
WPLOG_OFF => '10'
|
||||
);
|
||||
/**
|
||||
* Writes JavaScript to flush all pending ("buffered") data to
|
||||
* the Firefox or Safari console.
|
||||
*
|
||||
* @notes requires JQuery 1.2.6 for browser detection.
|
||||
* browser detection is deprecated in JQuery 1.3
|
||||
* @see http://docs.jquery.com/Utilities/jQuery.browser
|
||||
*/
|
||||
function flushLogMessages()
|
||||
{
|
||||
if ( count( $this->_buffer ) )
|
||||
{
|
||||
print '<script type="text/javascript">'."\n";
|
||||
print 'var $j=jQuery.noConflict();'."\n";
|
||||
print 'if ($j.browser.safari && window.console) {'."\n";
|
||||
foreach ( $this->_buffer as $line )
|
||||
{
|
||||
printf( 'window.console.%s("%s");', $line[0], $line[1] );
|
||||
print "\n";
|
||||
}
|
||||
print '} else if ($j.browser.mozilla && (\'console\' in window) && (\'firebug\' in console)) {'."\n";
|
||||
foreach ( $this->_buffer as $line )
|
||||
{
|
||||
printf( 'console.%s("%s");', $line[0], $line[1] );
|
||||
print "\n";
|
||||
}
|
||||
print '} else if ($j.browser.opera && window.opera && opera.postError) {'."\n";
|
||||
foreach ( $this->_buffer as $line )
|
||||
{
|
||||
printf( 'opera.postError("%s");', $line[1] );
|
||||
print "\n";
|
||||
}
|
||||
print "}\n";
|
||||
print "</script>\n";
|
||||
}
|
||||
;
|
||||
$this->_buffer = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Buffers $message to be flushed to the Firebug or Safari console.
|
||||
*
|
||||
* Adapted from the PEAR_Log library
|
||||
*
|
||||
* @return boolean true
|
||||
* @param mixed $message String or object containing the message to log.
|
||||
* @param const $msgType[optional] type of message. Valid values are:
|
||||
* WPLOG_ERR. WPLOG_WARNING, WPLOG_INFO, WPLOG_DEBUG
|
||||
*/
|
||||
function log( $message, $msgType = null )
|
||||
{
|
||||
/* backtrace */
|
||||
$bTrace = debug_backtrace(); // assoc array
|
||||
|
||||
/* If a log message type hasn't been specified, use the default value. */
|
||||
if ( $msgType === null )
|
||||
{
|
||||
$msgType = $this->_defaultMsgType;
|
||||
}
|
||||
|
||||
// verify the status type and output only priority messages (based on wp-config setup)
|
||||
if(!$this->isMsgVisible($msgType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Extract the string representation of the message. */
|
||||
$message = $this->_extractMessage( $message );
|
||||
|
||||
/* normalize line breaks */
|
||||
$message = str_replace( "\r\n", "\n", $message );
|
||||
|
||||
/* escape line breaks */
|
||||
$message = str_replace( "\n", "\\n\\\n", $message );
|
||||
|
||||
/* escape quotes */
|
||||
$message = str_replace( '"', '\\"', $message );
|
||||
|
||||
/* Build the string containing the complete log line. */
|
||||
$line = sprintf('[%s: from line %d in file %s] %s',
|
||||
$this->_msgTypeLong[ $msgType ],
|
||||
$bTrace[0]['line'],
|
||||
basename($bTrace[0]['file']),
|
||||
$message );
|
||||
|
||||
// buffer method and line
|
||||
$this->_buffer[] = array($msgType, $line);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string representation of the message data (from the PEAR_Log library).
|
||||
*
|
||||
* If $message is an object, _extractMessage() will attempt to extract
|
||||
* the message text using a known method (such as a PEAR_Error object's
|
||||
* getMessage() method). If a known method, cannot be found, the
|
||||
* serialized representation of the object will be returned.
|
||||
*
|
||||
* If the message data is already a string, it will be returned unchanged.
|
||||
*
|
||||
* Adapted from the PEAR_Log library
|
||||
*
|
||||
* @param mixed $message The original message data. This may be a
|
||||
* string or any object.
|
||||
*
|
||||
* @return string The string representation of the message.
|
||||
*
|
||||
*/
|
||||
function _extractMessage( $message )
|
||||
{
|
||||
/*
|
||||
* If we've been given an object, attempt to extract the message using
|
||||
* a known method. If we can't find such a method, default to the
|
||||
* "human-readable" version of the object.
|
||||
*
|
||||
* We also use the human-readable format for arrays.
|
||||
*/
|
||||
if ( is_object( $message ) )
|
||||
{
|
||||
if ( method_exists( $message, 'getmessage' ) )
|
||||
{
|
||||
$message = $message->getMessage();
|
||||
}
|
||||
else if ( method_exists( $message, 'tostring' ) )
|
||||
{
|
||||
$message = $message->toString();
|
||||
}
|
||||
else if ( method_exists( $message, '__tostring' ) )
|
||||
{
|
||||
if ( version_compare( PHP_VERSION, '5.0.0', 'ge' ) )
|
||||
{
|
||||
$message = (string) $message;
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = $message->__toString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = var_export( $message, true );
|
||||
}
|
||||
}
|
||||
else if ( is_array( $message ) )
|
||||
{
|
||||
if ( isset($message['message']) )
|
||||
{
|
||||
if ( is_scalar( $message['message'] ) )
|
||||
{
|
||||
$message = $message['message'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = var_export( $message['message'], true );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = var_export( $message, true );
|
||||
}
|
||||
}
|
||||
else if ( is_bool( $message ) || $message === NULL )
|
||||
{
|
||||
$message = var_export( $message, true );
|
||||
}
|
||||
|
||||
/* Otherwise, we assume the message is a string. */
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Is the message for the logger visible, i.e. is the status approved for output in the config
|
||||
*
|
||||
* @param status_type $msg_status the status level
|
||||
*/
|
||||
function isMsgVisible($msg_status) {
|
||||
// verify that status for logging is set
|
||||
if(!defined('WPV_LOGGING_STATUS')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// use default off status if status not in the list
|
||||
if(!in_array(WPV_LOGGING_STATUS, $this->_msgTypeLong) ||
|
||||
!in_array($msg_status, $this->_msgTypeLong)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// verify priorities
|
||||
if( $this->_msgStatusPriority[$msg_status] >= $this->_msgStatusPriority[WPV_LOGGING_STATUS] ) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,347 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Frontend functions.
|
||||
*/
|
||||
|
||||
global $wp_version;
|
||||
|
||||
if (version_compare($wp_version, '3.3', '<')) {
|
||||
// add a the_content filter to allow types shortcodes to be closed.
|
||||
// This is a bit of a HACK for version 3.2.1 and less
|
||||
|
||||
add_filter('the_content', 'wpcf_fix_closed_types_shortcodes', 9, 1);
|
||||
add_filter('the_content', 'wpcf_fix_closed_types_shortcodes_after', 11, 1);
|
||||
|
||||
function wpcf_fix_closed_types_shortcodes($content) {
|
||||
$content = str_replace('][/types', ']###TYPES###[/types', $content);
|
||||
return $content;
|
||||
}
|
||||
|
||||
function wpcf_fix_closed_types_shortcodes_after($content) {
|
||||
$content = str_replace('###TYPES###', '', $content);
|
||||
return $content;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
add_shortcode('types', 'wpcf_shortcode');
|
||||
|
||||
function wpcf_shortcode($atts, $content = null, $code = '') {
|
||||
|
||||
// Switch the post if there is an attribute of 'id' in the shortcode.
|
||||
$post_id_atts = new WPV_wpcf_switch_post_from_attr_id($atts);
|
||||
|
||||
$atts = array_merge(array(
|
||||
'field' => false,
|
||||
'style' => '',
|
||||
'show_name' => false,
|
||||
'raw' => false,
|
||||
), $atts
|
||||
);
|
||||
if ($atts['field']) {
|
||||
return types_render_field($atts['field'], $atts, $content, $code);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls view function for specific field type.
|
||||
*
|
||||
* @param type $field
|
||||
* @param type $atts
|
||||
* @return type
|
||||
*/
|
||||
function types_render_field($field_id, $params, $content = null, $code = '') {
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
||||
global $post;
|
||||
|
||||
// Get field
|
||||
$field = wpcf_fields_get_field_by_slug($field_id);
|
||||
if (empty($field)) {
|
||||
if (!function_exists('wplogger')) {
|
||||
require_once WPCF_EMBEDDED_ABSPATH . '/common/wplogger.php';
|
||||
}
|
||||
global $wplogger;
|
||||
$wplogger->log('types_render_field call for missing field \''
|
||||
. $field_id. '\'', WPLOG_DEBUG);
|
||||
return '';
|
||||
}
|
||||
|
||||
// See if repetitive
|
||||
if (wpcf_admin_is_repetitive($field)) {
|
||||
$meta = get_post_meta($post->ID,
|
||||
wpcf_types_get_meta_prefix($field) . $field['slug'], false);
|
||||
if (!empty($meta)) {
|
||||
$output = '';
|
||||
|
||||
if (isset($params['index'])) {
|
||||
$index = $params['index'];
|
||||
} else {
|
||||
$index = '';
|
||||
}
|
||||
|
||||
// Allow wpv-for-each shortcode to set the index
|
||||
$index = apply_filters('wpv-for-each-index', $index);
|
||||
|
||||
|
||||
if ($index === '') {
|
||||
$output = array();
|
||||
foreach ($meta as $temp_key => $temp_value) {
|
||||
$params['field_value'] = $temp_value;
|
||||
$temp_output = types_render_field_single($field, $params,
|
||||
$content, $code);
|
||||
if (!empty($temp_output)) {
|
||||
$output[] = $temp_output;
|
||||
}
|
||||
}
|
||||
if (!empty($output) && isset($params['separator'])) {
|
||||
$output = implode($params['separator'], $output);
|
||||
} else if (!empty($output)) {
|
||||
$output = implode('', $output);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else if (isset($meta[$index])) {
|
||||
$params['field_value'] = $meta[$index];
|
||||
return types_render_field_single($field, $params, $content,
|
||||
$code);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
return $output;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$params['field_value'] = get_post_meta($post->ID,
|
||||
wpcf_types_get_meta_prefix($field) . $field['slug'], true);
|
||||
if ($params['field_value'] == '' && $field['type'] != 'checkbox') {
|
||||
return '';
|
||||
}
|
||||
return types_render_field_single($field, $params, $content, $code);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls view function for specific field type by single field.
|
||||
*
|
||||
* @param type $field
|
||||
* @param type $atts
|
||||
* @return type
|
||||
*/
|
||||
function types_render_field_single($field, $params, $content = null, $code = '') {
|
||||
global $post;
|
||||
|
||||
// Count fields (if there are duplicates)
|
||||
static $count = array();
|
||||
|
||||
// Count it
|
||||
if (!isset($count[$field['slug']])) {
|
||||
$count[$field['slug']] = 1;
|
||||
} else {
|
||||
$count[$field['slug']] += 1;
|
||||
}
|
||||
|
||||
// Load type
|
||||
$type = wpcf_fields_type_action($field['type']);
|
||||
|
||||
// If 'class' or 'style' parameters are set - force HTML output
|
||||
if ((!empty($params['class']) || !empty($params['style'])) && $field['type'] != 'date') {
|
||||
$params['output'] = 'html';
|
||||
}
|
||||
|
||||
// Apply filters to field value
|
||||
$params['field_value'] = apply_filters('wpcf_fields_value_display',
|
||||
$params['field_value'], $params);
|
||||
$params['field_value'] = apply_filters('wpcf_fields_slug_' . $field['slug'] . '_value_display',
|
||||
$params['field_value'], $params);
|
||||
$params['field_value'] = apply_filters('wpcf_fields_type_' . $field['type'] . '_value_display',
|
||||
$params['field_value'], $params);
|
||||
// To make sure
|
||||
if (is_string($params['field_value'])) {
|
||||
$params['field_value'] = addslashes(stripslashes($params['field_value']));
|
||||
}
|
||||
|
||||
// Set values
|
||||
$field['name'] = wpcf_translate('field ' . $field['id'] . ' name',
|
||||
$field['name']);
|
||||
$params['field'] = $field;
|
||||
$params['#content'] = htmlspecialchars($content);
|
||||
$params['#code'] = $code;
|
||||
|
||||
|
||||
$output = '';
|
||||
if (isset($params['raw']) && $params['raw'] == 'true') {
|
||||
// Skype is array
|
||||
if ($field['type'] == 'skype' && isset($params['field_value']['skypename'])) {
|
||||
$output = $params['field_value']['skypename'];
|
||||
} else {
|
||||
$output = $params['field_value'];
|
||||
}
|
||||
} else {
|
||||
$output = wpcf_fields_type_action($field['type'], 'view', $params);
|
||||
|
||||
// Convert to string
|
||||
if (!empty($output)) {
|
||||
$output = strval($output);
|
||||
}
|
||||
|
||||
// If no output
|
||||
if (empty($output) && !empty($params['field_value'])) {
|
||||
$output = wpcf_frontend_wrap_field_value($field,
|
||||
$params['field_value'], $params);
|
||||
$output = wpcf_frontend_wrap_field($field, $output, $params);
|
||||
} else if ($output != '__wpcf_skip_empty') {
|
||||
$output = wpcf_frontend_wrap_field_value($field, $output, $params);
|
||||
$output = wpcf_frontend_wrap_field($field, $output, $params);
|
||||
} else {
|
||||
$output = '';
|
||||
}
|
||||
|
||||
// Add count
|
||||
if (isset($count[$field['slug']]) && intval($count[$field['slug']]) > 1) {
|
||||
$add = '-' . intval($count[$field['slug']]);
|
||||
$output = str_replace('id="wpcf-field-' . $field['slug'] . '"',
|
||||
'id="wpcf-field-' . $field['slug'] . $add . '"', $output);
|
||||
}
|
||||
}
|
||||
|
||||
// Apply filters
|
||||
$output = strval(apply_filters('types_view', $output,
|
||||
$params['field_value'], $field['type'], $field['slug'],
|
||||
$field['name'], $params));
|
||||
|
||||
return htmlspecialchars_decode(stripslashes($output));
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps field content.
|
||||
*
|
||||
* @param type $field
|
||||
* @param type $content
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_frontend_wrap_field($field, $content, $params = array()) {
|
||||
if (isset($params['output']) && $params['output'] == 'html') {
|
||||
$class = array();
|
||||
if (!empty($params['class'])
|
||||
&& !in_array($field['type'],
|
||||
array('file', 'image', 'email', 'url', 'wysiwyg'))) {
|
||||
$class[] = $params['class'];
|
||||
}
|
||||
$class[] = 'wpcf-field-' . $field['type'] . ' wpcf-field-'
|
||||
. $field['slug'];
|
||||
// Add name if needed
|
||||
if (isset($params['show_name']) && $params['show_name'] == 'true'
|
||||
&& strpos($content,
|
||||
'class="wpcf-field-' . $field['type']
|
||||
. '-name ') === false) {
|
||||
$content = wpcf_frontend_wrap_field_name($field, $field['name'],
|
||||
$params) . $content;
|
||||
}
|
||||
$output = '<div id="wpcf-field-' . $field['slug'] . '"'
|
||||
. ' class="' . implode(' ', $class) . '"';
|
||||
if (!empty($params['style'])
|
||||
&& !in_array($field['type'],
|
||||
array('date', 'file', 'image', 'email', 'url', 'wysiwyg'))) {
|
||||
$output .= ' style="' . $params['style'] . '"';
|
||||
}
|
||||
$output .= '>' . $content . '</div>';
|
||||
return $output;
|
||||
} else {
|
||||
if (isset($params['show_name']) && $params['show_name'] == 'true'
|
||||
&& strpos($content, $field['name'] . ':') === false) {
|
||||
$content = wpcf_frontend_wrap_field_name($field,
|
||||
$params['field']['name'], $params) . $content;
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps field name.
|
||||
*
|
||||
* @param type $field
|
||||
* @param type $content
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_frontend_wrap_field_name($field, $content, $params = array()) {
|
||||
if (isset($params['output']) && $params['output'] == 'html') {
|
||||
$class = array();
|
||||
if ($field['type'] == 'checkboxes' && isset($params['option'])) {
|
||||
if (isset($params['field']['data']['options'][$params['option']]['title'])) {
|
||||
$content = $params['field']['data']['options'][$params['option']]['title'];
|
||||
}
|
||||
$class[] = $params['option'] . '-name';
|
||||
}
|
||||
if (!in_array($field['type'],
|
||||
array('file', 'image', 'email', 'url', 'wysiwyg'))
|
||||
&& !empty($params['class'])) {
|
||||
$class[] = $params['class'];
|
||||
}
|
||||
$class[] = 'wpcf-field-name wpcf-field-' . $field['type'] . ' wpcf-field-'
|
||||
. $field['slug'] . '-name';
|
||||
if ($field['type'] == 'wysiwyg' || $field['type'] == 'textarea') {
|
||||
$output = '<div class="' . implode(' ', $class) . '"';
|
||||
if (!empty($params['style'])) {
|
||||
$output .= ' style="' . $params['style'] . '"';
|
||||
}
|
||||
$output .= '>' . stripslashes($content) . ':</div> ';
|
||||
return $output;
|
||||
}
|
||||
$output = '<span class="' . implode(' ', $class) . '"';
|
||||
if (!empty($params['style'])
|
||||
&& !in_array($field['type'],
|
||||
array('date', 'file', 'image', 'email', 'url', 'wysiwyg'))) {
|
||||
$output .= ' style="' . $params['style'] . '"';
|
||||
}
|
||||
$output .= '>' . stripslashes($content) . ':</span> ';
|
||||
return $output;
|
||||
} else {
|
||||
return stripslashes($content) . ': ';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps field value.
|
||||
*
|
||||
* @param type $field
|
||||
* @param type $content
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_frontend_wrap_field_value($field, $content, $params = array()) {
|
||||
if (isset($params['output']) && $params['output'] == 'html') {
|
||||
$class = array();
|
||||
if ($field['type'] == 'checkboxes' && isset($params['option'])) {
|
||||
$class[] = $params['option'] . '-value';
|
||||
}
|
||||
if (!empty($params['class'])
|
||||
&& !in_array($field['type'],
|
||||
array('file', 'image', 'email', 'url', 'wysiwyg'))) {
|
||||
$class[] = $params['class'];
|
||||
}
|
||||
$class[] = 'wpcf-field-value wpcf-field-' . $field['type']
|
||||
. '-value wpcf-field-' . $field['slug'] . '-value';
|
||||
if ($field['type'] == 'skype' || $field['type'] == 'image' || ($field['type'] == 'date' && $params['style'] == 'calendar')
|
||||
|| $field['type'] == 'wysiwyg' || $field['type'] == 'textarea') {
|
||||
$output = '<div class="' . implode(' ', $class) . '"';
|
||||
if (!empty($params['style'])
|
||||
&& !in_array($field['type'],
|
||||
array('date', 'file', 'image', 'email', 'url', 'wysiwyg'))) {
|
||||
$output .= ' style="' . $params['style'] . '"';
|
||||
}
|
||||
$output .= '>' . stripslashes($content) . '</div>';
|
||||
return $output;
|
||||
}
|
||||
$output = '<span class="' . implode(' ', $class) . '"';
|
||||
if (!empty($params['style'])
|
||||
&& !in_array($field['type'],
|
||||
array('date', 'file', 'image', 'email', 'url', 'wysiwyg'))) {
|
||||
$output .= ' style="' . $params['style'] . '"';
|
||||
}
|
||||
$output .= '>' . stripslashes($content) . '</span>';
|
||||
return $output;
|
||||
} else {
|
||||
return stripslashes($content);
|
||||
}
|
||||
}
|
||||
@ -1,425 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* All AJAX calls go here.
|
||||
*/
|
||||
function wpcf_ajax_embedded() {
|
||||
if (!isset($_REQUEST['_wpnonce'])
|
||||
|| !wp_verify_nonce($_REQUEST['_wpnonce'], $_REQUEST['wpcf_action'])) {
|
||||
die('Verification failed');
|
||||
}
|
||||
switch ($_REQUEST['wpcf_action']) {
|
||||
|
||||
case 'editor_insert_date':
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/date.php';
|
||||
wpcf_fields_date_editor_form();
|
||||
break;
|
||||
|
||||
case 'insert_skype_button':
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/skype.php';
|
||||
wpcf_fields_skype_meta_box_ajax();
|
||||
break;
|
||||
|
||||
case 'editor_callback':
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
||||
$field = wpcf_admin_fields_get_field($_GET['field_id']);
|
||||
if (!empty($field)) {
|
||||
$function = 'wpcf_fields_' . $field['type'] . '_editor_callback';
|
||||
if (function_exists($function)) {
|
||||
call_user_func($function);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'dismiss_message':
|
||||
if (isset($_GET['id'])) {
|
||||
$messages = get_option('wpcf_dismissed_messages', array());
|
||||
$messages[] = $_GET['id'];
|
||||
update_option('wpcf_dismissed_messages', $messages);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'pr_add_child_post':
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
|
||||
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
|
||||
$output = 'Passed wrong parameters';
|
||||
if (isset($_GET['post_id']) && isset($_GET['post_type_child']) && isset($_GET['post_type_parent'])) {
|
||||
$relationships = get_option('wpcf_post_relationship', array());
|
||||
$post = get_post($_GET['post_id']);
|
||||
$post_type = $_GET['post_type_child'];
|
||||
$parent_post_type = $_GET['post_type_parent'];
|
||||
$data = $relationships[$parent_post_type][$post_type];
|
||||
$output = wpcf_pr_admin_post_meta_box_has_row($post, $post_type,
|
||||
$data, $parent_post_type, false);
|
||||
}
|
||||
echo json_encode(array(
|
||||
'output' => $output,
|
||||
));
|
||||
break;
|
||||
|
||||
case 'pr_save_child_post':
|
||||
ob_start(); // Try to catch any errors
|
||||
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
|
||||
$output = array();
|
||||
if (isset($_GET['post_id']) && isset($_GET['post_type_child'])) {
|
||||
$post = get_post($_GET['post_id']);
|
||||
$post_type = $_GET['post_type_child'];
|
||||
$output = wpcf_pr_admin_save_post_hook($_GET['post_id']);
|
||||
}
|
||||
$errors = ob_get_clean();
|
||||
echo json_encode(array(
|
||||
'output' => $output,
|
||||
'errors' => $errors
|
||||
));
|
||||
break;
|
||||
|
||||
case 'pr_delete_child_post':
|
||||
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
|
||||
$output = 'Passed wrong parameters';
|
||||
if (isset($_GET['post_id'])) {
|
||||
$output = wpcf_pr_admin_delete_child_item($_GET['post_id']);
|
||||
}
|
||||
echo json_encode(array(
|
||||
'output' => $output,
|
||||
));
|
||||
break;
|
||||
|
||||
case 'pr-update-belongs':
|
||||
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
|
||||
$output = 'Passed wrong parameters';
|
||||
if (isset($_POST['post_id']) && isset($_POST['wpcf_pr_belongs'])) {
|
||||
$output = wpcf_pr_admin_update_belongs($_POST['post_id'],
|
||||
$_POST['wpcf_pr_belongs']);
|
||||
}
|
||||
echo json_encode(array(
|
||||
'output' => $output,
|
||||
));
|
||||
break;
|
||||
|
||||
case 'pr_pagination':
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
|
||||
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
|
||||
$output = 'Passed wrong parameters';
|
||||
if (isset($_GET['post_id']) && isset($_GET['post_type'])) {
|
||||
$post = get_post($_GET['post_id']);
|
||||
$post_type = $_GET['post_type'];
|
||||
$has = wpcf_pr_admin_get_has($post->post_type);
|
||||
$output = wpcf_pr_admin_post_meta_box_has_form($post,
|
||||
$post_type, $has[$post_type], $post->post_type);
|
||||
}
|
||||
echo json_encode(array(
|
||||
'output' => $output,
|
||||
));
|
||||
break;
|
||||
|
||||
case 'pr_sort':
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
|
||||
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
|
||||
$output = 'Passed wrong parameters';
|
||||
if (isset($_GET['field']) && isset($_GET['sort']) && isset($_GET['post_id']) && isset($_GET['post_type'])) {
|
||||
$post = get_post($_GET['post_id']);
|
||||
$post_type = $_GET['post_type'];
|
||||
$has = wpcf_pr_admin_get_has($post->post_type);
|
||||
$output = wpcf_pr_admin_post_meta_box_has_form($post,
|
||||
$post_type, $has[$post_type], $post->post_type);
|
||||
}
|
||||
echo json_encode(array(
|
||||
'output' => $output,
|
||||
));
|
||||
break;
|
||||
|
||||
case 'pr_sort_parent':
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
|
||||
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
|
||||
$output = 'Passed wrong parameters';
|
||||
if (isset($_GET['field']) && isset($_GET['sort']) && isset($_GET['post_id']) && isset($_GET['post_type'])) {
|
||||
$post = get_post($_GET['post_id']);
|
||||
$post_type = $_GET['post_type'];
|
||||
$has = wpcf_pr_admin_get_has($post->post_type);
|
||||
$output = wpcf_pr_admin_post_meta_box_has_form($post,
|
||||
$post_type, $has[$post_type], $post->post_type);
|
||||
}
|
||||
echo json_encode(array(
|
||||
'output' => $output,
|
||||
));
|
||||
break;
|
||||
|
||||
case 'pr_save_all':
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
|
||||
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
|
||||
$output = array();
|
||||
if (isset($_POST['post_id']) && isset($_POST['wpcf_post_relationship'])) {
|
||||
$output = wpcf_pr_admin_save_post_hook($_POST['post_id']);
|
||||
}
|
||||
echo json_encode(array(
|
||||
'output' => $output,
|
||||
));
|
||||
break;
|
||||
|
||||
case 'repetitive_add':
|
||||
if (isset($_GET['field_id'])) {
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
|
||||
$field = wpcf_admin_fields_get_field($_GET['field_id']);
|
||||
// Pass as normal
|
||||
unset($field['data']['repetitive']);
|
||||
$fields = array($_GET['field_id'] => $field);
|
||||
$element = wpcf_admin_post_process_fields(false, $fields, false,
|
||||
false, 'repetitive');
|
||||
if ($field['type'] == 'skype') {
|
||||
$key = key($element);
|
||||
unset($element[$key]['#title']);
|
||||
echo json_encode(array(
|
||||
'output' => wpcf_form_simple($element) . wpcf_form_render_js_validation('#post',
|
||||
false),
|
||||
));
|
||||
} else {
|
||||
$element = array_shift($element);
|
||||
if (!in_array($field['type'], array('checkbox'))) {
|
||||
unset($element['#title']);
|
||||
}
|
||||
echo json_encode(array(
|
||||
'output' => wpcf_form_simple(array('repetitive' => $element)) . wpcf_form_render_js_validation('#post',
|
||||
false),
|
||||
));
|
||||
}
|
||||
} else {
|
||||
echo json_encode(array(
|
||||
'output' => 'params missing',
|
||||
));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'repetitive_delete':
|
||||
if (isset($_POST['post_id']) && isset($_POST['field_id']) && isset($_POST['old_value'])) {
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
||||
$field = wpcf_admin_fields_get_field($_POST['field_id']);
|
||||
if (!empty($field)) {
|
||||
if ($field['type'] == 'date') {
|
||||
delete_post_meta($_POST['post_id'],
|
||||
wpcf_types_get_meta_prefix($field) . $field['id'],
|
||||
strtotime(base64_decode($_POST['old_value'])));
|
||||
} else if ($field['type'] == 'skype') {
|
||||
delete_post_meta($_POST['post_id'],
|
||||
wpcf_types_get_meta_prefix($field) . $field['id'],
|
||||
unserialize(base64_decode($_POST['old_value'])));
|
||||
} else {
|
||||
delete_post_meta($_POST['post_id'],
|
||||
wpcf_types_get_meta_prefix($field) . $field['id'],
|
||||
base64_decode($_POST['old_value']));
|
||||
}
|
||||
echo json_encode(array(
|
||||
'output' => 'deleted',
|
||||
));
|
||||
} else {
|
||||
echo json_encode(array(
|
||||
'output' => 'field not found',
|
||||
));
|
||||
}
|
||||
} else {
|
||||
echo json_encode(array(
|
||||
'output' => 'params missing',
|
||||
));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'cd_verify':
|
||||
if (!is_array($_POST['wpcf'])) {
|
||||
die();
|
||||
}
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/conditional-display.php';
|
||||
$passed_fields = array();
|
||||
$failed_fields = array();
|
||||
$post = false;
|
||||
if (isset($_SERVER['HTTP_REFERER'])) {
|
||||
$split = explode('?', $_SERVER['HTTP_REFERER']);
|
||||
if (isset($split[1])) {
|
||||
parse_str($split[1], $vars);
|
||||
if (isset($vars['post'])) {
|
||||
$_POST['post_ID'] = $vars['post'];
|
||||
$post = get_post($vars['post']);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Dummy post
|
||||
if (!$post) {
|
||||
$post = new stdClass();
|
||||
$post->ID = 1;
|
||||
}
|
||||
// Filter meta values (switch them with $_POST values)
|
||||
add_filter('get_post_metadata',
|
||||
'wpcf_cd_meta_ajax_validation_filter', 10, 4);
|
||||
|
||||
foreach ($_POST['wpcf'] as $field_id => $field_value) {
|
||||
$element = array();
|
||||
$field = wpcf_admin_fields_get_field($field_id);
|
||||
if (!empty($field['data']['conditional_display']['conditions'])) {
|
||||
$element = wpcf_cd_post_edit_field_filter($element, $field,
|
||||
$post, 'group');
|
||||
if (isset($element['__wpcf_cd_status']) && $element['__wpcf_cd_status'] == 'passed') {
|
||||
$passed_fields[] = 'wpcf[' . $field['id'] . ']';
|
||||
} else {
|
||||
$failed_fields[] = 'wpcf[' . $field['id'] . ']';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove filter meta values (switch them with $_POST values)
|
||||
remove_filter('get_post_metadata',
|
||||
'wpcf_cd_meta_ajax_validation_filter', 10, 4);
|
||||
|
||||
if (!empty($passed_fields) || !empty($failed_fields)) {
|
||||
$execute = '';
|
||||
foreach ($passed_fields as $field_name) {
|
||||
$execute .= 'jQuery(\'[name^="' . $field_name . '"]\').parents(\'.wpcf-cd\').show().removeClass(\'wpcf-cd-failed\').addClass(\'wpcf-cd-passed\');' . " ";
|
||||
}
|
||||
foreach ($failed_fields as $field_name) {
|
||||
$execute .= 'jQuery(\'[name^="' . $field_name . '"]\').parents(\'.wpcf-cd\').hide().addClass(\'wpcf-cd-failed\').removeClass(\'wpcf-cd-passed\');' . " ";
|
||||
}
|
||||
echo json_encode(array(
|
||||
'output' => '',
|
||||
'execute' => $execute,
|
||||
'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
|
||||
));
|
||||
}
|
||||
die();
|
||||
break;
|
||||
|
||||
case 'cd_group_verify':
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/conditional-display.php';
|
||||
$group = wpcf_admin_fields_get_group($_POST['group_id']);
|
||||
if (empty($group)) {
|
||||
echo json_encode(array(
|
||||
'output' => ''
|
||||
));
|
||||
die();
|
||||
}
|
||||
$execute = '';
|
||||
$group['conditional_display'] = get_post_meta($group['id'],
|
||||
'_wpcf_conditional_display', true);
|
||||
// Filter meta values (switch them with $_POST values)
|
||||
add_filter('get_post_metadata',
|
||||
'wpcf_cd_meta_ajax_validation_filter', 10, 4);
|
||||
$post = false;
|
||||
if (isset($_SERVER['HTTP_REFERER'])) {
|
||||
$split = explode('?', $_SERVER['HTTP_REFERER']);
|
||||
if (isset($split[1])) {
|
||||
parse_str($split[1], $vars);
|
||||
if (isset($vars['post'])) {
|
||||
$_POST['post_ID'] = $vars['post'];
|
||||
$post = get_post($vars['post']);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Dummy post
|
||||
if (!$post) {
|
||||
$post = new stdClass();
|
||||
$post->ID = 1;
|
||||
}
|
||||
if (!empty($group['conditional_display']['conditions'])) {
|
||||
$result = wpcf_cd_post_groups_filter(array(0 => $group), $post,
|
||||
'group');
|
||||
if (!empty($result)) {
|
||||
$result = array_shift($result);
|
||||
$passed = $result['_conditional_display'] == 'passed' ? true : false;
|
||||
} else {
|
||||
$passed = false;
|
||||
}
|
||||
if (!$passed) {
|
||||
$execute = 'jQuery("#' . $group['slug'] . '").slideUp().find(".wpcf-cd-group").addClass(\'wpcf-cd-group-failed\').removeClass(\'wpcf-cd-group-passed\').hide();';
|
||||
} else {
|
||||
$execute = 'jQuery("#' . $group['slug'] . '").show().find(".wpcf-cd-group").addClass(\'wpcf-cd-group-passed\').removeClass(\'wpcf-cd-group-failed\').slideDown();';
|
||||
}
|
||||
}
|
||||
// Remove filter meta values (switch them with $_POST values)
|
||||
remove_filter('get_post_metadata',
|
||||
'wpcf_cd_meta_ajax_validation_filter', 10, 4);
|
||||
echo json_encode(array(
|
||||
'output' => '',
|
||||
'execute' => $execute,
|
||||
'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
|
||||
));
|
||||
break;
|
||||
|
||||
case 'pr_verify':
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/conditional-display.php';
|
||||
$passed_fields = array();
|
||||
$failed_fields = array();
|
||||
$post = false;
|
||||
if (isset($_SERVER['HTTP_REFERER'])) {
|
||||
$split = explode('?', $_SERVER['HTTP_REFERER']);
|
||||
if (isset($split[1])) {
|
||||
parse_str($split[1], $vars);
|
||||
if (isset($vars['post'])) {
|
||||
$_POST['post_ID'] = $vars['post'];
|
||||
$post = get_post($vars['post']);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Dummy post
|
||||
if (!$post) {
|
||||
$post = new stdClass();
|
||||
$post->ID = 1;
|
||||
}
|
||||
// Filter meta values (switch them with $_POST values)
|
||||
add_filter('get_post_metadata',
|
||||
'wpcf_cd_pr_meta_ajax_validation_filter', 10, 4);
|
||||
|
||||
if (isset($_POST['wpcf_post_relationship'])) {
|
||||
$child_post_id = key($_POST['wpcf_post_relationship']);
|
||||
$data = $_POST['wpcf_post_relationship'] = array_shift($_POST['wpcf_post_relationship']);
|
||||
foreach ($data as $field_id => $field_value) {
|
||||
$element = array();
|
||||
$field = wpcf_admin_fields_get_field(str_replace(WPCF_META_PREFIX,
|
||||
'', $field_id));
|
||||
if (!empty($field['data']['conditional_display']['conditions'])) {
|
||||
$element = wpcf_cd_post_edit_field_filter($element,
|
||||
$field, $post, 'group');
|
||||
if (isset($element['__wpcf_cd_status']) && $element['__wpcf_cd_status'] == 'passed') {
|
||||
$passed_fields[] = 'wpcf_post_relationship_'
|
||||
. $child_post_id . '_' . $field['id'];
|
||||
} else {
|
||||
$failed_fields[] = 'wpcf_post_relationship_'
|
||||
. $child_post_id . '_' . $field['id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove filter meta values (switch them with $_POST values)
|
||||
remove_filter('get_post_metadata',
|
||||
'wpcf_cd_pr_meta_ajax_validation_filter', 10, 4);
|
||||
|
||||
if (!empty($passed_fields) || !empty($failed_fields)) {
|
||||
$execute = '';
|
||||
foreach ($passed_fields as $field_name) {
|
||||
$execute .= 'jQuery(\'#' . $field_name . '\').parents(\'.wpcf-cd\').show().removeClass(\'wpcf-cd-failed\').addClass(\'wpcf-cd-passed\');' . " ";
|
||||
}
|
||||
foreach ($failed_fields as $field_name) {
|
||||
$execute .= 'jQuery(\'#' . $field_name . '\').parents(\'.wpcf-cd\').hide().addClass(\'wpcf-cd-failed\').removeClass(\'wpcf-cd-passed\');' . " ";
|
||||
}
|
||||
echo json_encode(array(
|
||||
'output' => '',
|
||||
'execute' => $execute,
|
||||
'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
|
||||
));
|
||||
}
|
||||
die();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (function_exists('wpcf_ajax')) {
|
||||
wpcf_ajax();
|
||||
}
|
||||
die();
|
||||
}
|
||||
@ -1,443 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Conditional display embedded code.
|
||||
*/
|
||||
add_filter('wpcf_post_edit_field', 'wpcf_cd_post_edit_field_filter', 10, 4);
|
||||
add_filter('wpcf_post_groups', 'wpcf_cd_post_groups_filter', 10, 3);
|
||||
|
||||
if (!function_exists('wplogger')) {
|
||||
require_once WPCF_EMBEDDED_ABSPATH . '/common/wplogger.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters groups on post edit page.
|
||||
*
|
||||
* @param type $groups
|
||||
* @param type $post
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_cd_post_groups_filter($groups, $post, $context) {
|
||||
if ($context != 'group') {
|
||||
return $groups;
|
||||
}
|
||||
foreach ($groups as $key => &$group) {
|
||||
$meta_conditional = !isset($group['conditional_display']) ? get_post_meta($group['id'],
|
||||
'_wpcf_conditional_display', true) : $group['conditional_display'];
|
||||
if (!empty($meta_conditional['conditions'])) {
|
||||
$group['conditional_display'] = $meta_conditional;
|
||||
add_action('admin_head', 'wpcf_cd_add_group_js');
|
||||
if (empty($post->ID)) {
|
||||
$group['_conditional_display'] = 'failed';
|
||||
continue;
|
||||
}
|
||||
$passed = true;
|
||||
if (isset($group['conditional_display']['custom_use'])) {
|
||||
if (empty($group['conditional_display']['custom'])) {
|
||||
$group['_conditional_display'] = 'failed';
|
||||
continue;
|
||||
}
|
||||
|
||||
$evaluate = trim(stripslashes($group['conditional_display']['custom']));
|
||||
// Add quotes = > < >= <= === <> !==
|
||||
$strings_count = preg_match_all('/[=|==|===|<=|<==|<===|>=|>==|>===|\!===|\!==|\!=|<>]\s(?!\$)(\w*)[\)|\$|\W]/',
|
||||
$evaluate, $matches);
|
||||
if (!empty($matches[1])) {
|
||||
foreach ($matches[1] as $temp_match) {
|
||||
$temp_replace = is_numeric($temp_match) ? $temp_match : '\'' . $temp_match . '\'';
|
||||
$evaluate = str_replace(' ' . $temp_match . ')',
|
||||
' ' . $temp_replace . ')', $evaluate);
|
||||
}
|
||||
}
|
||||
preg_match_all('/\$([^\s]*)/',
|
||||
$group['conditional_display']['custom'], $matches);
|
||||
if (empty($matches)) {
|
||||
$group['_conditional_display'] = 'failed';
|
||||
continue;
|
||||
}
|
||||
$fields = array();
|
||||
foreach ($matches[1] as $key => $field_name) {
|
||||
$fields[$field_name] = wpcf_types_get_meta_prefix(wpcf_admin_fields_get_field($field_name)) . $field_name;
|
||||
wpcf_cd_add_group_js('add', $field_name, '', '',
|
||||
$group['id']);
|
||||
}
|
||||
$fields['evaluate'] = $evaluate;
|
||||
$check = wpv_condition($fields);
|
||||
$passed = $check;
|
||||
if (!is_bool($check)) {
|
||||
$passed = false;
|
||||
$group['_conditional_display'] = 'failed';
|
||||
} else if ($check) {
|
||||
$group['_conditional_display'] = 'passed';
|
||||
} else {
|
||||
$group['_conditional_display'] = 'failed';
|
||||
}
|
||||
} else {
|
||||
$passed_all = true;
|
||||
$passed_one = false;
|
||||
foreach ($group['conditional_display']['conditions'] as $condition) {
|
||||
wpcf_cd_add_group_js('add', $condition['field'],
|
||||
$condition['value'], $condition['operation'],
|
||||
$group['id']);
|
||||
$value = get_post_meta($post->ID,
|
||||
wpcf_types_get_meta_prefix($condition['field']) . $condition['field'],
|
||||
true);
|
||||
$check = wpcf_cd_admin_compare($condition['operation'],
|
||||
$value, $condition['value']);
|
||||
if (!$check) {
|
||||
$passed_all = false;
|
||||
} else {
|
||||
$passed_one = true;
|
||||
}
|
||||
}
|
||||
if (!$passed_all && $group['conditional_display']['relation'] == 'AND') {
|
||||
$passed = false;
|
||||
}
|
||||
if (!$passed_one && $group['conditional_display']['relation'] == 'OR') {
|
||||
$passed = false;
|
||||
}
|
||||
}
|
||||
if (!$passed) {
|
||||
$group['_conditional_display'] = 'failed';
|
||||
} else {
|
||||
$group['_conditional_display'] = 'passed';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there is conditional display.
|
||||
*
|
||||
* @param type $element
|
||||
* @param type $field
|
||||
* @param type $post
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_cd_post_edit_field_filter($element, $field, $post,
|
||||
$context = 'group') {
|
||||
if (defined('DOING_AJAX') && $context == 'repetitive') {
|
||||
return $element;
|
||||
}
|
||||
if (!empty($field['data']['conditional_display']['conditions'])) {
|
||||
add_action('admin_head', 'wpcf_cd_add_field_js');
|
||||
$passed = true;
|
||||
if (empty($post->ID)) {
|
||||
$passed = false;
|
||||
} else if (isset($field['data']['conditional_display']['custom_use'])) {
|
||||
if (empty($field['data']['conditional_display']['custom'])) {
|
||||
return array();
|
||||
}
|
||||
$evaluate = trim(stripslashes($field['data']['conditional_display']['custom']));
|
||||
// Add quotes = > < >= <= === <> !==
|
||||
$strings_count = preg_match_all('/[=|==|===|<=|<==|<===|>=|>==|>===|\!===|\!==|\!=|<>]\s(?!\$)(\w*)[\)|\$|\W]/',
|
||||
$evaluate, $matches);
|
||||
if (!empty($matches[1])) {
|
||||
foreach ($matches[1] as $temp_match) {
|
||||
$temp_replace = is_numeric($temp_match) ? $temp_match : '\'' . $temp_match . '\'';
|
||||
$evaluate = str_replace(' ' . $temp_match . ')',
|
||||
' ' . $temp_replace . ')', $evaluate);
|
||||
}
|
||||
}
|
||||
preg_match_all('/\$([^\s]*)/',
|
||||
$field['data']['conditional_display']['custom'], $matches);
|
||||
if (empty($matches)) {
|
||||
$passed = false;
|
||||
} else {
|
||||
$fields = array();
|
||||
foreach ($matches[1] as $key => $field_name) {
|
||||
$fields[$field_name] = wpcf_types_get_meta_prefix(wpcf_admin_fields_get_field($field_name)) . $field_name;
|
||||
}
|
||||
$fields['evaluate'] = $evaluate;
|
||||
$check = wpv_condition($fields);
|
||||
if (!is_bool($check)) {
|
||||
$passed = false;
|
||||
} else {
|
||||
$passed = $check;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$passed_all = true;
|
||||
$passed_one = false;
|
||||
foreach ($field['data']['conditional_display']['conditions'] as $condition) {
|
||||
// This is malformed condition and should be treated as passed
|
||||
// @TODO Approve it
|
||||
if (!isset($condition['field']) || !isset($condition['operation'])
|
||||
|| !isset($condition['value'])) {
|
||||
$passed_one = true;
|
||||
continue;
|
||||
}
|
||||
$value = get_post_meta($post->ID,
|
||||
wpcf_types_get_meta_prefix($condition['field']) . $condition['field'],
|
||||
true);
|
||||
$check = wpcf_cd_admin_compare($condition['operation'], $value,
|
||||
$condition['value']);
|
||||
if (!$check) {
|
||||
$passed_all = false;
|
||||
} else {
|
||||
$passed_one = true;
|
||||
}
|
||||
}
|
||||
if (!$passed_all && $field['data']['conditional_display']['relation'] == 'AND') {
|
||||
$passed = false;
|
||||
}
|
||||
if (!$passed_one && $field['data']['conditional_display']['relation'] == 'OR') {
|
||||
$passed = false;
|
||||
}
|
||||
}
|
||||
if (!$passed) {
|
||||
$wrap = '<div class="wpcf-cd wpcf-cd-failed" style="display:none;">';
|
||||
$element['__wpcf_cd_status'] = 'failed';
|
||||
} else {
|
||||
$wrap = '<div class="wpcf-cd wpcf-cd-passed">';
|
||||
$element['__wpcf_cd_status'] = 'passed';
|
||||
}
|
||||
if (isset($element['#before'])) {
|
||||
$element['#before'] = $wrap . $element['#before'];
|
||||
} else {
|
||||
$element['#before'] = $wrap;
|
||||
}
|
||||
if (isset($element['#after'])) {
|
||||
$element['#after'] = $element['#after'] . '</div>';
|
||||
} else {
|
||||
$element['#after'] = '</div>';
|
||||
}
|
||||
}
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Operations.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_cd_admin_operations() {
|
||||
return array(
|
||||
'=' => __('Equal to', 'wpcf'),
|
||||
'>' => __('Larger than', 'wpcf'),
|
||||
'<' => __('Less than', 'wpcf'),
|
||||
'>=' => __('Larger or equal to', 'wpcf'),
|
||||
'<=' => __('Less or equal to', 'wpcf'),
|
||||
'===' => __('Identical to', 'wpcf'),
|
||||
'<>' => __('Not identical to', 'wpcf'),
|
||||
'!==' => __('Strictly not equal', 'wpcf'),
|
||||
// 'between' => __('Between', 'wpcf'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares values.
|
||||
*
|
||||
* @param type $operation
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_cd_admin_compare($operation) {
|
||||
$args = func_get_args();
|
||||
switch ($operation) {
|
||||
case '=':
|
||||
return $args[1] == $args[2];
|
||||
break;
|
||||
|
||||
case '>':
|
||||
return intval($args[1]) > intval($args[2]);
|
||||
break;
|
||||
|
||||
case '>=':
|
||||
return intval($args[1]) >= intval($args[2]);
|
||||
break;
|
||||
|
||||
case '<':
|
||||
return intval($args[1]) < intval($args[2]);
|
||||
break;
|
||||
|
||||
case '<=':
|
||||
return intval($args[1]) <= intval($args[2]);
|
||||
break;
|
||||
|
||||
case '===':
|
||||
return $args[1] === $args[2];
|
||||
break;
|
||||
|
||||
case '!==':
|
||||
return $args[1] !== $args[2];
|
||||
break;
|
||||
|
||||
case '<>':
|
||||
return $args[1] <> $args[2];
|
||||
break;
|
||||
|
||||
case 'between':
|
||||
return intval($args[1]) > intval($args[2]) && intval($args[1]) < intval($args[3]);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* JS for fields AJAX.
|
||||
*/
|
||||
function wpcf_cd_add_field_js() {
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function(){
|
||||
jQuery('.wpcf-cd').each(function(){
|
||||
jQuery(this).parents('.inside').find(':input').each(function(){
|
||||
if (jQuery(this).hasClass('wpcf-cd-binded')) {
|
||||
return false;
|
||||
}
|
||||
jQuery(this).addClass('wpcf-cd-binded');
|
||||
if (jQuery(this).hasClass('radio')
|
||||
|| jQuery(this).hasClass('checkbox')) {
|
||||
jQuery(this).bind('click', function(){
|
||||
wpcfCdVerify(jQuery(this), jQuery(this).attr('name'), jQuery(this).val());
|
||||
});
|
||||
} else if (jQuery(this).hasClass('select')) {
|
||||
jQuery(this).bind('change', function(){
|
||||
wpcfCdVerify(jQuery(this), jQuery(this).attr('name'), jQuery(this).val());
|
||||
});
|
||||
} else {
|
||||
jQuery(this).bind('blur', function(){
|
||||
wpcfCdVerify(jQuery(this), jQuery(this).attr('name'), jQuery(this).val());
|
||||
});
|
||||
}
|
||||
});
|
||||
if (typeof adminpage !== 'undefined' && adminpage == 'post-new-php') {
|
||||
wpcfCdVerify(jQuery(this), jQuery(this).attr('name'), jQuery(this).val());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function wpcfCdVerify(object, name, value) {
|
||||
if (object.hasClass('wpcf-pr-binded')) {
|
||||
return false;
|
||||
}
|
||||
var form = object.parents('.inside').find(':input');
|
||||
jQuery.ajax({
|
||||
url: '<?php echo admin_url('admin-ajax.php'); ?>',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: form.serialize()+'<?php echo '&action=wpcf_ajax&wpcf_action=cd_verify&_wpnonce=' . wp_create_nonce('cd_verify'); ?>',
|
||||
cache: false,
|
||||
beforeSend: function() {
|
||||
},
|
||||
success: function(data) {
|
||||
if (data != null) {
|
||||
if (typeof data.execute != 'undefined'
|
||||
&& (typeof data.wpcf_nonce_ajax_callback != 'undefined'
|
||||
&& data.wpcf_nonce_ajax_callback == wpcf_nonce_ajax_callback)) {
|
||||
eval(data.execute);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Register JS for groups AJAX.
|
||||
*
|
||||
* @staticvar array $conditions
|
||||
* @param type $call
|
||||
* @param type $field
|
||||
* @param type $value
|
||||
* @param type $condition
|
||||
* @param type $group_id
|
||||
* @return string
|
||||
*/
|
||||
function wpcf_cd_add_group_js($call, $field = false, $value = false,
|
||||
$condition = false, $group_id = false) {
|
||||
static $conditions = array();
|
||||
if ($call == 'add') {
|
||||
$conditions[$field] = array(
|
||||
'value' => $value,
|
||||
'condition' => $condition,
|
||||
'group_id' => $group_id
|
||||
);
|
||||
return '';
|
||||
}
|
||||
wpcf_cd_add_group_js_render($conditions);
|
||||
}
|
||||
|
||||
/**
|
||||
* JS for groups AJAX.
|
||||
*
|
||||
* @param type $conditions
|
||||
*/
|
||||
function wpcf_cd_add_group_js_render($conditions = array()) {
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function(){
|
||||
<?php
|
||||
foreach ($conditions as $field => $data) {
|
||||
|
||||
?>
|
||||
jQuery('[name="wpcf[<?php echo $field; ?>]"]').bind('blur', function(){
|
||||
wpcfCdGroupVerify(jQuery(this), jQuery(this).attr('name'), jQuery(this).val(), <?php echo $data['group_id']; ?>);
|
||||
});
|
||||
<?php
|
||||
}
|
||||
|
||||
?>
|
||||
jQuery('.wpcf-cd-group-failed').parents('.postbox').hide();
|
||||
});
|
||||
|
||||
function wpcfCdGroupVerify(object, name, value, group_id) {
|
||||
var form = jQuery('#post');
|
||||
jQuery.ajax({
|
||||
url: '<?php echo admin_url('admin-ajax.php'); ?>',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: form.serialize()+'&group_id='+group_id+'<?php echo '&action=wpcf_ajax&wpcf_action=cd_group_verify&_wpnonce=' . wp_create_nonce('cd_group_verify'); ?>',
|
||||
cache: false,
|
||||
beforeSend: function() {
|
||||
},
|
||||
success: function(data) {
|
||||
if (data != null) {
|
||||
if (typeof data.execute != 'undefined'
|
||||
&& (typeof data.wpcf_nonce_ajax_callback != 'undefined'
|
||||
&& data.wpcf_nonce_ajax_callback == wpcf_nonce_ajax_callback)) {
|
||||
eval(data.execute);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes $_POST values for AJAX call.
|
||||
*
|
||||
* @param type $null
|
||||
* @param type $object_id
|
||||
* @param type $meta_key
|
||||
* @param type $single
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_cd_meta_ajax_validation_filter($null, $object_id, $meta_key,
|
||||
$single) {
|
||||
$meta_key = str_replace('wpcf-', '', $meta_key);
|
||||
return isset($_POST['wpcf'][$meta_key]) ? $_POST['wpcf'][$meta_key] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes $_POST values for AJAX call.
|
||||
*
|
||||
* @param type $null
|
||||
* @param type $object_id
|
||||
* @param type $meta_key
|
||||
* @param type $single
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_cd_pr_meta_ajax_validation_filter($null, $object_id, $meta_key,
|
||||
$single) {
|
||||
return isset($_POST['wpcf_post_relationship'][$meta_key]) ? $_POST['wpcf_post_relationship'][$meta_key] : '';
|
||||
}
|
||||
@ -1,167 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Custom taxonomies registration.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returna default custom taxonomy structure.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function wpcf_custom_taxonomies_default() {
|
||||
return array(
|
||||
'slug' => '',
|
||||
'description' => '',
|
||||
'supports' => array(),
|
||||
'public' => true,
|
||||
'show_in_nav_menus' => true,
|
||||
'hierarchical' => false,
|
||||
'show_ui' => true,
|
||||
'show_tagcloud' => true,
|
||||
'update_count_callback' => '',
|
||||
'query_var_enabled' => true,
|
||||
'query_var' => '',
|
||||
'rewrite' => array(
|
||||
'enabled' => true,
|
||||
'slug' => '',
|
||||
'with_front' => true,
|
||||
'hierarchical' => true
|
||||
),
|
||||
'capabilities' => false,
|
||||
'labels' => array(
|
||||
'name' => '',
|
||||
'singular_name' => '',
|
||||
'search_items' => 'Search %s',
|
||||
'popular_items' => 'Popular %s',
|
||||
'all_items' => 'All %s',
|
||||
'parent_item' => 'Parent %s',
|
||||
'parent_item_colon' => 'Parent %s:',
|
||||
'edit_item' => 'Edit %s',
|
||||
'update_item' => 'Update %s',
|
||||
'add_new_item' => 'Add New %s',
|
||||
'new_item_name' => 'New %s Name',
|
||||
'separate_items_with_commas' => 'Separate %s with commas',
|
||||
'add_or_remove_items' => 'Add or remove %s',
|
||||
'choose_from_most_used' => 'Choose from the most used %s',
|
||||
'menu_name' => '%s',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inits custom taxonomies.
|
||||
*/
|
||||
function wpcf_custom_taxonomies_init() {
|
||||
$custom_taxonomies = get_option('wpcf-custom-taxonomies', array());
|
||||
if (!empty($custom_taxonomies)) {
|
||||
foreach ($custom_taxonomies as $taxonomy => $data) {
|
||||
wpcf_custom_taxonomies_register($taxonomy, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers custom taxonomies.
|
||||
*
|
||||
* @param type $post_type
|
||||
* @param type $data
|
||||
*/
|
||||
function wpcf_custom_taxonomies_register($taxonomy, $data) {
|
||||
if (!empty($data['disabled'])) {
|
||||
return false;
|
||||
}
|
||||
// Set object types
|
||||
if (!empty($data['supports']) && is_array($data['supports'])) {
|
||||
$object_types = array_keys($data['supports']);
|
||||
} else {
|
||||
$object_types = array();
|
||||
}
|
||||
$data = wpcf_custom_taxonomies_translate($taxonomy, $data);
|
||||
// Set labels
|
||||
if (!empty($data['labels'])) {
|
||||
if (!isset($data['labels']['name'])) {
|
||||
$data['labels']['name'] = $taxonomy;
|
||||
}
|
||||
if (!isset($data['labels']['singular_name'])) {
|
||||
$data['labels']['singular_name'] = $data['labels']['name'];
|
||||
}
|
||||
foreach ($data['labels'] as $label_key => $label) {
|
||||
$data['labels'][$label_key] = $label = stripslashes($label);
|
||||
switch ($label_key) {
|
||||
case 'parent_item':
|
||||
case 'parent_item_colon':
|
||||
case 'edit_item':
|
||||
case 'update_item':
|
||||
case 'add_new_item':
|
||||
case 'new_item_name':
|
||||
$data['labels'][$label_key] = sprintf($label,
|
||||
$data['labels']['singular_name']);
|
||||
break;
|
||||
|
||||
case 'search_items':
|
||||
case 'popular_items':
|
||||
case 'all_items':
|
||||
case 'separate_items_with_commas':
|
||||
case 'add_or_remove_items':
|
||||
case 'choose_from_most_used':
|
||||
case 'menu_name':
|
||||
$data['labels'][$label_key] = sprintf($label,
|
||||
$data['labels']['name']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$data['description'] = !empty($data['description']) ? htmlspecialchars(stripslashes($data['description']),
|
||||
ENT_QUOTES) : '';
|
||||
$data['public'] = (empty($data['public']) || strval($data['public']) == 'hidden') ? false : true;
|
||||
$data['show_ui'] = (empty($data['show_ui']) || !$data['public']) ? false : true;
|
||||
$data['hierarchical'] = (empty($data['hierarchical']) || $data['hierarchical'] == 'flat') ? false : true;
|
||||
$data['show_in_nav_menus'] = !empty($data['show_in_nav_menus']);
|
||||
if (empty($data['query_var_enabled'])) {
|
||||
$data['query_var'] = false;
|
||||
} else if (empty($data['query_var'])) {
|
||||
$data['query_var'] = true;
|
||||
}
|
||||
if (!empty($data['rewrite']['enabled'])) {
|
||||
$data['rewrite']['with_front'] = !empty($data['rewrite']['with_front']);
|
||||
$data['rewrite']['hierarchical'] = !empty($data['rewrite']['hierarchical']);
|
||||
// Make sure that rewrite/slug has a value
|
||||
if (!isset($data['rewrite']['slug']) || $data['rewrite']['slug'] == '') {
|
||||
$data['rewrite']['slug'] = $data['slug'];
|
||||
}
|
||||
} else {
|
||||
$data['rewrite'] = false;
|
||||
}
|
||||
// Force removing capabilities here
|
||||
unset($data['capabilities']);
|
||||
register_taxonomy($taxonomy, $object_types, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates data.
|
||||
*
|
||||
* @param type $post_type
|
||||
* @param type $data
|
||||
*/
|
||||
function wpcf_custom_taxonomies_translate($taxonomy, $data) {
|
||||
if (!function_exists('icl_t')) {
|
||||
return $data;
|
||||
}
|
||||
$default = wpcf_custom_taxonomies_default();
|
||||
if (!empty($data['description'])) {
|
||||
$data['description'] = wpcf_translate($taxonomy . ' description',
|
||||
$data['description'], 'Types-TAX');
|
||||
}
|
||||
foreach ($data['labels'] as $label => $string) {
|
||||
if ($label == 'name' || $label == 'singular_name') {
|
||||
$data['labels'][$label] = wpcf_translate($taxonomy . ' ' . $label,
|
||||
$string, 'Types-TAX');
|
||||
continue;
|
||||
}
|
||||
if (!isset($default['labels'][$label]) || $string !== $default['labels'][$label]) {
|
||||
$data['labels'][$label] = wpcf_translate($taxonomy . ' ' . $label,
|
||||
$string, 'Types-TAX');
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
@ -1,226 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Returns default custom type structure.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function wpcf_custom_types_default() {
|
||||
return array(
|
||||
'labels' => array(
|
||||
'name' => '',
|
||||
'singular_name' => '',
|
||||
'add_new' => 'Add New',
|
||||
'add_new_item' => 'Add New %s',
|
||||
// 'edit' => 'Edit',
|
||||
'edit_item' => 'Edit %s',
|
||||
'new_item' => 'New %s',
|
||||
// 'view' => 'View',
|
||||
'view_item' => 'View %s',
|
||||
'search_items' => 'Search %s',
|
||||
'not_found' => 'No %s found',
|
||||
'not_found_in_trash' => 'No %s found in Trash',
|
||||
'parent_item_colon' => 'Parent %s',
|
||||
'menu_name' => '%s',
|
||||
'all_items' => '%s',
|
||||
),
|
||||
'slug' => '',
|
||||
'description' => '',
|
||||
'public' => true,
|
||||
'capabilities' => false,
|
||||
'menu_position' => null,
|
||||
'menu_icon' => '',
|
||||
'taxonomies' => array(
|
||||
'category' => false,
|
||||
'post_tag' => false,
|
||||
),
|
||||
'supports' => array(
|
||||
'title' => true,
|
||||
'editor' => true,
|
||||
'trackbacks' => false,
|
||||
'comments' => false,
|
||||
'revisions' => false,
|
||||
'author' => false,
|
||||
'excerpt' => false,
|
||||
'thumbnail' => false,
|
||||
'custom-fields' => false,
|
||||
'page-attributes' => false,
|
||||
'post-formats' => false,
|
||||
),
|
||||
'rewrite' => array(
|
||||
'enabled' => true,
|
||||
'slug' => '',
|
||||
'with_front' => true,
|
||||
'feeds' => true,
|
||||
'pages' => true,
|
||||
),
|
||||
'has_archive' => true,
|
||||
'show_ui' => true,
|
||||
'show_in_menu' => true,
|
||||
'show_in_menu_page' => '',
|
||||
'publicly_queryable' => true,
|
||||
'exclude_from_search' => false,
|
||||
'hierarchical' => false,
|
||||
'query_var_enabled' => true,
|
||||
'query_var' => '',
|
||||
'can_export' => true,
|
||||
'show_in_nav_menus' => true,
|
||||
'register_meta_box_cb' => '',
|
||||
'permalink_epmask' => 'EP_PERMALINK'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inits custom types.
|
||||
*/
|
||||
function wpcf_custom_types_init() {
|
||||
$custom_types = get_option('wpcf-custom-types', array());
|
||||
if (!empty($custom_types)) {
|
||||
foreach ($custom_types as $post_type => $data) {
|
||||
wpcf_custom_types_register($post_type, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers custom post type.
|
||||
*
|
||||
* @param type $post_type
|
||||
* @param type $data
|
||||
*/
|
||||
function wpcf_custom_types_register($post_type, $data) {
|
||||
if (!empty($data['disabled'])) {
|
||||
return false;
|
||||
}
|
||||
$data = wpcf_custom_types_translate($post_type, $data);
|
||||
// Set labels
|
||||
if (!empty($data['labels'])) {
|
||||
if (!isset($data['labels']['name'])) {
|
||||
$data['labels']['name'] = $post_type;
|
||||
}
|
||||
if (!isset($data['labels']['singular_name'])) {
|
||||
$data['labels']['singular_name'] = $data['labels']['name'];
|
||||
}
|
||||
foreach ($data['labels'] as $label_key => $label) {
|
||||
$data['labels'][$label_key] = $label = stripslashes($label);
|
||||
switch ($label_key) {
|
||||
case 'add_new_item':
|
||||
case 'edit_item':
|
||||
case 'new_item':
|
||||
case 'view_item':
|
||||
case 'parent_item_colon':
|
||||
$data['labels'][$label_key] = sprintf($label,
|
||||
$data['labels']['singular_name']);
|
||||
break;
|
||||
|
||||
case 'search_items':
|
||||
case 'all_items':
|
||||
case 'not_found':
|
||||
case 'not_found_in_trash':
|
||||
case 'menu_name':
|
||||
$data['labels'][$label_key] = sprintf($label,
|
||||
$data['labels']['name']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$data['description'] = !empty($data['description']) ? htmlspecialchars(stripslashes($data['description']),
|
||||
ENT_QUOTES) : '';
|
||||
$data['public'] = (empty($data['public']) || strval($data['public']) == 'hidden') ? false : true;
|
||||
$data['publicly_queryable'] = !empty($data['publicly_queryable']);
|
||||
$data['exclude_from_search'] = !empty($data['exclude_from_search']);
|
||||
$data['show_ui'] = (empty($data['show_ui']) || !$data['public']) ? false : true;
|
||||
if (empty($data['menu_position'])) {
|
||||
unset($data['menu_position']);
|
||||
} else {
|
||||
$data['menu_position'] = intval($data['menu_position']);
|
||||
}
|
||||
$data['hierarchical'] = !empty($data['hierarchical']);
|
||||
$data['supports'] = !empty($data['supports']) && is_array($data['supports']) ? array_keys($data['supports']) : array();
|
||||
$data['taxonomies'] = !empty($data['taxonomies']) && is_array($data['taxonomies']) ? array_keys($data['taxonomies']) : array();
|
||||
$data['has_archive'] = !empty($data['has_archive']);
|
||||
$data['can_export'] = !empty($data['can_export']);
|
||||
$data['show_in_nav_menus'] = !empty($data['show_in_nav_menus']);
|
||||
$data['show_in_menu'] = !empty($data['show_in_menu']);
|
||||
if (empty($data['query_var_enabled'])) {
|
||||
$data['query_var'] = false;
|
||||
} else if (empty($data['query_var'])) {
|
||||
$data['query_var'] = true;
|
||||
}
|
||||
if (!empty($data['show_in_menu_page'])) {
|
||||
$data['show_in_menu'] = $data['show_in_menu_page'];
|
||||
}
|
||||
if (empty($data['menu_icon'])) {
|
||||
unset($data['menu_icon']);
|
||||
} else {
|
||||
$data['menu_icon'] = stripslashes($data['menu_icon']);
|
||||
if (strpos($data['menu_icon'], '[theme]') !== false) {
|
||||
$data['menu_icon'] = str_replace('[theme]',
|
||||
get_stylesheet_directory_uri(), $data['menu_icon']);
|
||||
}
|
||||
}
|
||||
if (!empty($data['rewrite']['enabled'])) {
|
||||
$data['rewrite']['with_front'] = !empty($data['rewrite']['with_front']);
|
||||
$data['rewrite']['feeds'] = !empty($data['rewrite']['feeds']);
|
||||
$data['rewrite']['pages'] = !empty($data['rewrite']['pages']);
|
||||
if (!empty($data['rewrite']['custom']) && $data['rewrite']['custom'] != 'custom') {
|
||||
unset($data['rewrite']['slug']);
|
||||
}
|
||||
unset($data['rewrite']['custom']);
|
||||
} else {
|
||||
$data['rewrite'] = false;
|
||||
}
|
||||
|
||||
// Set permalink_epmask
|
||||
if (!empty($data['permalink_epmask'])) {
|
||||
$data['permalink_epmask'] = constant($data['permalink_epmask']);
|
||||
}
|
||||
|
||||
$args = register_post_type($post_type, apply_filters('wpcf_type', $data, $post_type));
|
||||
do_action('wpcf_type_registered', $args);
|
||||
|
||||
// Add the standard tags and categoires if the're set.
|
||||
$body = '';
|
||||
if (in_array('post_tag', $data['taxonomies'])) {
|
||||
$body = 'register_taxonomy_for_object_type("post_tag", "' . $post_type . '");';
|
||||
}
|
||||
if (in_array('category', $data['taxonomies'])) {
|
||||
$body .= 'register_taxonomy_for_object_type("category", "' . $post_type . '");';
|
||||
}
|
||||
|
||||
// make sure the function name is OK
|
||||
$post_type = str_replace('-', '_', $post_type);
|
||||
if ($body != '' && !function_exists($post_type . '_add_default_taxes')) {
|
||||
eval('function ' . $post_type . '_add_default_taxes() { ' . $body . ' }');
|
||||
add_action('init', $post_type . '_add_default_taxes');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates data.
|
||||
*
|
||||
* @param type $post_type
|
||||
* @param type $data
|
||||
*/
|
||||
function wpcf_custom_types_translate($post_type, $data) {
|
||||
if (!function_exists('icl_t')) {
|
||||
return $data;
|
||||
}
|
||||
$default = wpcf_custom_types_default();
|
||||
if (!empty($data['description'])) {
|
||||
$data['description'] = wpcf_translate($post_type . ' description',
|
||||
$data['description'], 'Types-CPT');
|
||||
}
|
||||
foreach ($data['labels'] as $label => $string) {
|
||||
if ($label == 'name' || $label == 'singular_name') {
|
||||
$data['labels'][$label] = wpcf_translate($post_type . ' ' . $label,
|
||||
$string, 'Types-CPT');
|
||||
continue;
|
||||
}
|
||||
if (!isset($default['labels'][$label]) || $string !== $default['labels'][$label]) {
|
||||
$data['labels'][$label] = wpcf_translate($post_type . ' ' . $label,
|
||||
$string, 'Types-CPT');
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
@ -1,4 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
*/
|
||||
@ -1,547 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Gets all groups.
|
||||
*
|
||||
* @global type $wpdb
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_admin_fields_get_groups() {
|
||||
$groups = get_posts('numberposts=-1&post_type=wp-types-group&post_status=null');
|
||||
if (!empty($groups)) {
|
||||
foreach ($groups as $k => $group) {
|
||||
$groups[$k] = wpcf_admin_fields_adjust_group($group);
|
||||
}
|
||||
}
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets group by ID.
|
||||
*
|
||||
* @global type $wpdb
|
||||
* @param type $group_id
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_admin_fields_get_group($group_id) {
|
||||
return wpcf_admin_fields_adjust_group(get_post($group_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts post data.
|
||||
*
|
||||
* @param type $post
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_admin_fields_adjust_group($post) {
|
||||
if (empty($post)) {
|
||||
return false;
|
||||
}
|
||||
$group = array();
|
||||
$group['id'] = $post->ID;
|
||||
$group['slug'] = $post->post_name;
|
||||
$group['name'] = $post->post_title;
|
||||
$group['description'] = $post->post_content;
|
||||
$group['meta_box_context'] = 'normal';
|
||||
$group['meta_box_priority'] = 'high';
|
||||
$group['is_active'] = $post->post_status == 'publish' ? true : false;
|
||||
$group['filters_association'] = get_post_meta($post->ID,
|
||||
'_wp_types_group_filters_association', true);
|
||||
|
||||
return $group;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all fields.
|
||||
*
|
||||
* @global type $wpdb
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_admin_fields_get_fields($only_active = false,
|
||||
$disabled_by_type = false, $strictly_active = false) {
|
||||
$required_data = array('id', 'name', 'type', 'slug');
|
||||
$fields = get_option('wpcf-fields', array());
|
||||
foreach ($fields as $k => $v) {
|
||||
$data = wpcf_fields_type_action($v['type']);
|
||||
if (empty($data)) {
|
||||
unset($fields[$k]);
|
||||
continue;
|
||||
}
|
||||
if (isset($data['wp_version'])
|
||||
&& wpcf_compare_wp_version($data['wp_version'], '<')) {
|
||||
unset($fields[$k]);
|
||||
continue;
|
||||
}
|
||||
if ($strictly_active) {
|
||||
if (!empty($v['data']['disabled']) || !empty($v['data']['disabled_by_type'])) {
|
||||
unset($fields[$k]);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (($only_active && !empty($v['data']['disabled']))) {
|
||||
unset($fields[$k]);
|
||||
continue;
|
||||
}
|
||||
if (!$disabled_by_type && !empty($v['data']['disabled_by_type'])) {
|
||||
unset($fields[$k]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
foreach ($required_data as $required) {
|
||||
if (!isset($v[$required])) {
|
||||
if (!defined('WPCF_RUNNING_EMBEDDED')) {
|
||||
$link = admin_url('admin-ajax.php?action=wpcf_ajax&wpcf_action=delete_field&field_id=' . $v['id'] . '&_wpnonce=' . wp_create_nonce('delete_field'));
|
||||
wp_enqueue_script('wpcf-fields-edit',
|
||||
WPCF_RES_RELPATH . '/js/basic.js',
|
||||
array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable'),
|
||||
WPCF_VERSION);
|
||||
$message = sprintf(__('Invalid field "%s". %sDelete it%s',
|
||||
'wpcf'), $v['id'],
|
||||
'<a href="' . $link . '" class="wpcf-ajax-link" onclick="jQuery(this).parent().parent().fadeOut();">',
|
||||
'</a>');
|
||||
}
|
||||
unset($fields[$k]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets field by ID.
|
||||
*
|
||||
* @global type $wpdb
|
||||
* @param type $field_id
|
||||
* @param type $only_active
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_admin_fields_get_field($field_id, $only_active = false,
|
||||
$disabled_by_type = false, $strictly_active = false) {
|
||||
$fields = wpcf_admin_fields_get_fields($only_active, $disabled_by_type,
|
||||
$strictly_active);
|
||||
if (!empty($fields[$field_id])) {
|
||||
$data = wpcf_fields_type_action($fields[$field_id]['type']);
|
||||
if (isset($data['wp_version'])
|
||||
&& wpcf_compare_wp_version($data['wp_version'], '<')) {
|
||||
return array();
|
||||
}
|
||||
$fields[$field_id]['id'] = $field_id;
|
||||
return $fields[$field_id];
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets field by slug.
|
||||
*
|
||||
* @global type $wpdb
|
||||
* @param type $slug
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_get_field_by_slug($slug) {
|
||||
return wpcf_admin_fields_get_field($slug);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all fields that belong to specific group.
|
||||
*
|
||||
* @global type $wpdb
|
||||
* @param type $group_id
|
||||
* @param type $key
|
||||
* @param type $only_active
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_admin_fields_get_fields_by_group($group_id, $key = 'slug',
|
||||
$only_active = false, $disabled_by_type = false,
|
||||
$strictly_active = false) {
|
||||
static $cache = array();
|
||||
$cache_key = md5($group_id . $key . $only_active . $disabled_by_type . $strictly_active);
|
||||
if (isset($cache[$cache_key])) {
|
||||
return $cache[$cache_key];
|
||||
}
|
||||
$group_fields = get_post_meta($group_id, '_wp_types_group_fields', true);
|
||||
if (empty($group_fields)) {
|
||||
return array();
|
||||
}
|
||||
$group_fields = explode(',', trim($group_fields, ','));
|
||||
$fields = wpcf_admin_fields_get_fields($only_active, $disabled_by_type,
|
||||
$strictly_active);
|
||||
$results = array();
|
||||
foreach ($group_fields as $field_id) {
|
||||
if (!isset($fields[$field_id])) {
|
||||
continue;
|
||||
}
|
||||
$field = wpcf_admin_fields_get_field($field_id);
|
||||
if (!empty($field)) {
|
||||
$results[$field_id] = $field;
|
||||
}
|
||||
}
|
||||
$cache[$cache_key] = $results;
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets groups that have specific term.
|
||||
*
|
||||
* @global type $wpdb
|
||||
* @param type $term_id
|
||||
* @param type $fetch_empty
|
||||
* @param type $only_active
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_admin_fields_get_groups_by_term($term_id = false,
|
||||
$fetch_empty = true, $post_type = false, $only_active = true) {
|
||||
$args = array();
|
||||
$args['post_type'] = 'wp-types-group';
|
||||
$args['numberposts'] = -1;
|
||||
// Active
|
||||
if ($only_active) {
|
||||
$args['post_status'] = 'publish';
|
||||
}
|
||||
// Fetch empty
|
||||
if ($fetch_empty) {
|
||||
if ($term_id) {
|
||||
$args['meta_query']['relation'] = 'OR';
|
||||
$args['meta_query'][] = array(
|
||||
'key' => '_wp_types_group_terms',
|
||||
'value' => ',' . $term_id . ',',
|
||||
'compare' => 'LIKE',
|
||||
);
|
||||
}
|
||||
$args['meta_query'][] = array(
|
||||
'key' => '_wp_types_group_terms',
|
||||
'value' => 'all',
|
||||
'compare' => '=',
|
||||
);
|
||||
} else if ($term_id) {
|
||||
$args['meta_query'] = array(
|
||||
array(
|
||||
'key' => '_wp_types_group_terms',
|
||||
'value' => ',' . $term_id . ',',
|
||||
'compare' => 'LIKE',
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
$groups = get_posts($args);
|
||||
foreach ($groups as $k => $post) {
|
||||
$temp = get_post_meta($post->ID, '_wp_types_group_post_types', true);
|
||||
if ($fetch_empty && $temp == 'all') {
|
||||
$groups[$k] = wpcf_admin_fields_adjust_group($post);
|
||||
} else if (strpos($temp, ',' . $post_type . ',') !== false) {
|
||||
$groups[$k] = wpcf_admin_fields_adjust_group($post);
|
||||
} else {
|
||||
unset($groups[$k]);
|
||||
}
|
||||
}
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets groups that have specific post_type.
|
||||
*
|
||||
* @global type $wpdb
|
||||
* @param type $post_type
|
||||
* @param type $fetch_empty
|
||||
* @param type $only_active
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_admin_get_groups_by_post_type($post_type, $fetch_empty = true,
|
||||
$terms = null, $only_active = true) {
|
||||
$args = array();
|
||||
$args['post_type'] = 'wp-types-group';
|
||||
$args['numberposts'] = -1;
|
||||
// Active
|
||||
if ($only_active) {
|
||||
$args['post_status'] = 'publish';
|
||||
}
|
||||
// Fetch empty
|
||||
if ($fetch_empty) {
|
||||
$args['meta_query'] = array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => '_wp_types_group_post_types',
|
||||
'value' => ',' . $post_type . ',',
|
||||
'compare' => 'LIKE',
|
||||
),
|
||||
array(
|
||||
'key' => '_wp_types_group_post_types',
|
||||
'value' => 'all',
|
||||
'compare' => '=',
|
||||
),
|
||||
);
|
||||
} else {
|
||||
$args['meta_query'] = array(
|
||||
array(
|
||||
'key' => '_wp_types_group_post_types',
|
||||
'value' => ',' . $post_type . ',',
|
||||
'compare' => 'LIKE',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$results_by_post_type = array();
|
||||
$results_by_terms = array();
|
||||
|
||||
// Get posts by post type
|
||||
$groups = get_posts($args);
|
||||
if (!empty($groups)) {
|
||||
foreach ($groups as $key => $group) {
|
||||
$group = wpcf_admin_fields_adjust_group($group);
|
||||
$results_by_post_type[$group['id']] = $group;
|
||||
}
|
||||
}
|
||||
|
||||
// Distinct terms
|
||||
if (!is_null($terms)) {
|
||||
if (!empty($terms)) {
|
||||
// $args['meta_query'] = array('relation' => 'OR');
|
||||
$terms_sql = array();
|
||||
$add = '';
|
||||
if ($fetch_empty) {
|
||||
$add = " OR m.meta_value LIKE 'all'";
|
||||
}
|
||||
foreach ($terms as $term) {
|
||||
$terms_sql[] = $term;
|
||||
}
|
||||
$terms_sql = "AND (m.meta_value LIKE '%%," . implode(",%%' OR m.meta_value LIKE '%%,",
|
||||
$terms) . ",%%' $add)";
|
||||
global $wpdb;
|
||||
$terms_sql = "SELECT * FROM $wpdb->posts p
|
||||
JOIN $wpdb->postmeta m
|
||||
WHERE p.post_type='wp-types-group' AND p.post_status='publish'
|
||||
AND p.ID = m.post_id AND m.meta_key='_wp_types_group_terms'
|
||||
$terms_sql";
|
||||
$groups = $wpdb->get_results($terms_sql);
|
||||
if (!empty($groups)) {
|
||||
foreach ($groups as $key => $group) {
|
||||
$group = wpcf_admin_fields_adjust_group($group);
|
||||
$results_by_terms[$group['id']] = $group;
|
||||
}
|
||||
}
|
||||
foreach ($results_by_post_type as $key => $value) {
|
||||
if (!array_key_exists($key, $results_by_terms)) {
|
||||
unset($results_by_post_type[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $results_by_post_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets groups that have specific template.
|
||||
*
|
||||
* @global type $wpdb
|
||||
* @param type $post_type
|
||||
* @param type $fetch_empty
|
||||
* @param type $only_active
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_admin_get_groups_by_template($templates = array('default'),
|
||||
$fetch_empty = true, $only_active = true) {
|
||||
$args = array();
|
||||
$args['post_type'] = 'wp-types-group';
|
||||
$args['numberposts'] = -1;
|
||||
$meta_query = array();
|
||||
// Active
|
||||
if ($only_active) {
|
||||
$args['post_status'] = 'publish';
|
||||
}
|
||||
|
||||
// Fetch empty
|
||||
if ($fetch_empty) {
|
||||
$args['meta_query'] = array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => '_wp_types_group_templates',
|
||||
'value' => 'all',
|
||||
'compare' => '=',
|
||||
),
|
||||
);
|
||||
} else {
|
||||
$args['meta_query'] = array(
|
||||
'relation' => 'OR');
|
||||
}
|
||||
foreach ($templates as $template) {
|
||||
$args['meta_query'][] = array(
|
||||
'key' => '_wp_types_group_templates',
|
||||
'value' => ',' . $template . ',',
|
||||
'compare' => 'LIKE',
|
||||
);
|
||||
}
|
||||
|
||||
$results_by_template = array();
|
||||
|
||||
// Get posts by template
|
||||
$groups = get_posts($args);
|
||||
if (!empty($groups)) {
|
||||
foreach ($groups as $key => $group) {
|
||||
$group = wpcf_admin_fields_adjust_group($group);
|
||||
$results_by_template[$group['id']] = $group;
|
||||
}
|
||||
}
|
||||
|
||||
return $results_by_template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads type configuration file and calls action.
|
||||
*
|
||||
* @param type $type
|
||||
* @param type $action
|
||||
* @param type $args
|
||||
*/
|
||||
function wpcf_fields_type_action($type, $func = '', $args = array()) {
|
||||
static $actions = array();
|
||||
$func_in = $func;
|
||||
|
||||
$md5_args = md5(serialize($args));
|
||||
|
||||
if (!isset($actions[$type . '-' . $func_in . '-' . $md5_args])) {
|
||||
$fields_registered = wpcf_admin_fields_get_available_types();
|
||||
if (isset($fields_registered[$type]) && isset($fields_registered[$type]['path'])) {
|
||||
$file = $fields_registered[$type]['path'];
|
||||
} else if (defined('WPCF_INC_ABSPATH')) {
|
||||
$file = WPCF_INC_ABSPATH . '/fields/' . $type . '.php';
|
||||
} else {
|
||||
$file = '';
|
||||
}
|
||||
$file_embedded = WPCF_EMBEDDED_INC_ABSPATH . '/fields/' . $type . '.php';
|
||||
if (file_exists($file) || file_exists($file_embedded)) {
|
||||
if (file_exists($file)) {
|
||||
require_once $file;
|
||||
}
|
||||
if (file_exists($file_embedded)) {
|
||||
require_once $file_embedded;
|
||||
}
|
||||
if (empty($func)) {
|
||||
$func = 'wpcf_fields_' . $type;
|
||||
} else {
|
||||
$func = 'wpcf_fields_' . $type . '_' . $func;
|
||||
}
|
||||
if (function_exists($func)) {
|
||||
$actions[$type . '-' . $func_in . '-' . $md5_args] = call_user_func($func, $args);
|
||||
} else {
|
||||
$actions[$type . '-' . $func_in . '-' . $md5_args] = array();
|
||||
}
|
||||
|
||||
} else {
|
||||
$actions[$type . '-' . $func_in . '-' . $md5_args] = array();
|
||||
}
|
||||
}
|
||||
return $actions[$type . '-' . $func_in . '-' . $md5_args];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns shortcode for specified field.
|
||||
*
|
||||
* @param type $field
|
||||
* @param type $add Additional attributes
|
||||
*/
|
||||
function wpcf_fields_get_shortcode($field, $add = '') {
|
||||
$shortcode = '[';
|
||||
$shortcode .= 'types field="' . $field['slug'] . '"' . $add;
|
||||
if (in_array($field['type'], array('textfield', 'textarea', 'wysiwyg'))) {
|
||||
$shortcode .= ' class="" style=""';
|
||||
}
|
||||
$shortcode .= '][/types]';
|
||||
$shortcode = apply_filters('wpcf_fields_shortcode', $shortcode, $field);
|
||||
$shortcode = apply_filters('wpcf_fields_shortcode_type_' . $field['type'],
|
||||
$shortcode, $field);
|
||||
$shortcode = apply_filters('wpcf_fields_shortcode_slug_' . $field['slug'],
|
||||
$shortcode, $field);
|
||||
return $shortcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders JS for inserting shortcode from thickbox popup to editor.
|
||||
*
|
||||
* @param type $shortcode
|
||||
*/
|
||||
function wpcf_admin_fields_popup_insert_shortcode_js($shortcode) {
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
window.parent.jQuery('#TB_closeWindowButton').trigger('click');
|
||||
if (window.parent.wpcfActiveEditor != false) {
|
||||
if (window.parent.jQuery('textarea#'+window.parent.wpcfActiveEditor+':visible').length) {
|
||||
// HTML editor
|
||||
window.parent.jQuery('textarea#'+window.parent.wpcfActiveEditor).insertAtCaret('<?php echo $shortcode; ?>');
|
||||
} else {
|
||||
// Visual editor
|
||||
window.parent.tinyMCE.execCommand('mceFocus', false, window.parent.wpcfActiveEditor);
|
||||
window.parent.tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<?php echo $shortcode; ?>');
|
||||
}
|
||||
} else if (window.parent.wpcfInsertMetaHTML == false) {
|
||||
if (window.parent.jQuery('textarea#content:visible').length) {
|
||||
// HTML editor
|
||||
window.parent.jQuery('textarea#content').insertAtCaret('<?php echo $shortcode; ?>');
|
||||
} else {
|
||||
// Visual editor
|
||||
window.parent.tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<?php echo $shortcode; ?>');
|
||||
}
|
||||
} else {
|
||||
window.parent.jQuery('#'+window.parent.wpcfInsertMetaHTML).insertAtCaret('<?php echo $shortcode; ?>');
|
||||
window.parent.wpcfInsertMetaHTML = false;
|
||||
}
|
||||
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves last field settings when inserting from toolbar.
|
||||
*
|
||||
* @param type $field_id
|
||||
* @param type $settings
|
||||
*/
|
||||
function wpcf_admin_fields_save_field_last_settings($field_id, $settings) {
|
||||
$data = get_user_meta(get_current_user_id(), 'wpcf-field-settings', true);
|
||||
$data[$field_id] = $settings;
|
||||
update_user_meta(get_current_user_id(), 'wpcf-field-settings', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets last field settings when inserting from toolbar.
|
||||
*
|
||||
* @param type $field_id
|
||||
*/
|
||||
function wpcf_admin_fields_get_field_last_settings($field_id) {
|
||||
$data = get_user_meta(get_current_user_id(), 'wpcf-field-settings', true);
|
||||
if (isset($data[$field_id])) {
|
||||
return $data[$field_id];
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all available types.
|
||||
*/
|
||||
function wpcf_admin_fields_get_available_types() {
|
||||
static $data = array();
|
||||
if (!empty($data)) {
|
||||
return $data;
|
||||
}
|
||||
foreach (glob(WPCF_EMBEDDED_INC_ABSPATH . '/fields/*.php') as $filename) {
|
||||
require_once $filename;
|
||||
if (function_exists('wpcf_fields_' . basename($filename, '.php'))) {
|
||||
$data_field = call_user_func('wpcf_fields_' . basename($filename,
|
||||
'.php'));
|
||||
if (!empty($data_field['wp_version'])) {
|
||||
if (wpcf_compare_wp_version($data_field['wp_version'], '>=')) {
|
||||
$data[basename($filename, '.php')] = $data_field;
|
||||
}
|
||||
} else {
|
||||
$data[basename($filename, '.php')] = $data_field;
|
||||
}
|
||||
}
|
||||
}
|
||||
$data = apply_filters('types_register_fields', $data);
|
||||
return $data;
|
||||
}
|
||||
@ -1,180 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Register data (called automatically).
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_checkbox() {
|
||||
return array(
|
||||
'id' => 'wpcf-checkbox',
|
||||
'title' => __('Checkbox', 'wpcf'),
|
||||
'description' => __('Checkbox', 'wpcf'),
|
||||
'validate' => array('required'),
|
||||
'meta_key_type' => 'BINARY',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Form data for post edit page.
|
||||
*
|
||||
* @param type $field
|
||||
*/
|
||||
function wpcf_fields_checkbox_meta_box_form($field) {
|
||||
$checked = false;
|
||||
$field['data']['set_value'] = stripslashes($field['data']['set_value']);
|
||||
if ($field['value'] == $field['data']['set_value']) {
|
||||
$checked = true;
|
||||
}
|
||||
// If post is new check if it's checked by default
|
||||
global $pagenow;
|
||||
if ($pagenow == 'post-new.php' && !empty($field['data']['checked'])) {
|
||||
$checked = true;
|
||||
}
|
||||
return array(
|
||||
'#type' => 'checkbox',
|
||||
'#value' => $field['data']['set_value'],
|
||||
'#default_value' => $checked,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor callback form.
|
||||
*/
|
||||
function wpcf_fields_checkbox_editor_callback() {
|
||||
$form = array();
|
||||
$value_not_selected = '';
|
||||
$value_selected = '';
|
||||
if (isset($_GET['field_id'])) {
|
||||
$field = wpcf_admin_fields_get_field($_GET['field_id']);
|
||||
if (!empty($field)) {
|
||||
if (isset($field['data']['display_value_not_selected'])) {
|
||||
$value_not_selected = $field['data']['display_value_not_selected'];
|
||||
}
|
||||
if (isset($field['data']['display_value_selected'])) {
|
||||
$value_selected = $field['data']['display_value_selected'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$form['#form']['callback'] = 'wpcf_fields_checkbox_editor_submit';
|
||||
$form['display'] = array(
|
||||
'#type' => 'radios',
|
||||
'#default_value' => 'db',
|
||||
'#name' => 'display',
|
||||
'#options' => array(
|
||||
'display_from_db' => array(
|
||||
'#title' => __('Display the value of this field from the database',
|
||||
'wpcf'),
|
||||
'#name' => 'display',
|
||||
'#value' => 'db',
|
||||
'#inline' => true,
|
||||
'#after' => '<br />'
|
||||
),
|
||||
'display_values' => array(
|
||||
'#title' => __('Show one of these two values:', 'wpcf'),
|
||||
'#name' => 'display',
|
||||
'#value' => 'value',
|
||||
),
|
||||
),
|
||||
'#inline' => true,
|
||||
);
|
||||
$form['display-value-1'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => '<td style="text-align:right;">'
|
||||
. __('Not selected:', 'wpcf') . '</td><td>',
|
||||
'#name' => 'display_value_not_selected',
|
||||
'#value' => $value_not_selected,
|
||||
'#inline' => true,
|
||||
'#before' => '<table><tr>',
|
||||
'#after' => '</td></tr>',
|
||||
);
|
||||
$form['display-value-2'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => '<td style="text-align:right;">'
|
||||
. __('Selected:', 'wpcf') . '</td><td>',
|
||||
'#name' => 'display_value_selected',
|
||||
'#value' => $value_selected,
|
||||
'#after' => '</tr></table>'
|
||||
);
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'submit',
|
||||
'#value' => __('Save Changes'),
|
||||
'#attributes' => array('class' => 'button-primary'),
|
||||
);
|
||||
$f = wpcf_form('wpcf-form', $form);
|
||||
wpcf_admin_ajax_head('Insert checkbox', 'wpcf');
|
||||
echo '<form method="post" action="">';
|
||||
echo $f->renderForm();
|
||||
echo '</form>';
|
||||
wpcf_admin_ajax_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor callback form submit.
|
||||
*/
|
||||
function wpcf_fields_checkbox_editor_submit() {
|
||||
$add = '';
|
||||
$field = wpcf_admin_fields_get_field($_GET['field_id']);
|
||||
if (!empty($field)) {
|
||||
if ($_POST['display'] == 'value') {
|
||||
$shortcode = '[types field="' . $field['slug'] . '" state="checked"]'
|
||||
. $_POST['display_value_selected']
|
||||
. '[/types] ';
|
||||
$shortcode .= '[types field="' . $field['slug'] . '" state="unchecked"]'
|
||||
. $_POST['display_value_not_selected']
|
||||
. '[/types]';
|
||||
} else {
|
||||
$shortcode = wpcf_fields_get_shortcode($field, $add);
|
||||
}
|
||||
echo wpcf_admin_fields_popup_insert_shortcode_js($shortcode);
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* View function.
|
||||
*
|
||||
* @param type $params
|
||||
*/
|
||||
function wpcf_fields_checkbox_view($params) {
|
||||
$output = '';
|
||||
if (isset($params['state']) && $params['state'] == 'unchecked' && empty($params['field_value'])) {
|
||||
return htmlspecialchars_decode($params['#content']);
|
||||
} else if (isset($params['state']) && $params['state'] == 'unchecked') {
|
||||
return '__wpcf_skip_empty';
|
||||
}
|
||||
|
||||
if (isset($params['state']) && $params['state'] == 'checked' && !empty($params['field_value'])) {
|
||||
return htmlspecialchars_decode($params['#content']);
|
||||
} else if (isset($params['state']) && $params['state'] == 'checked') {
|
||||
return '__wpcf_skip_empty';
|
||||
}
|
||||
if (!empty($params['#content'])) {
|
||||
return htmlspecialchars_decode($params['#content']);
|
||||
}
|
||||
|
||||
if ($params['field']['data']['display'] == 'db' && $params['field_value'] != '') {
|
||||
$field = wpcf_fields_get_field_by_slug($params['field']['slug']);
|
||||
$output = $field['data']['set_value'];
|
||||
|
||||
// Show the translated value if we have one.
|
||||
$output = wpcf_translate('field ' . $field['id'] . ' checkbox value',
|
||||
$output);
|
||||
} else if ($params['field']['data']['display'] == 'value'
|
||||
&& $params['field_value'] != '') {
|
||||
if (!empty($params['field']['data']['display_value_selected'])) {
|
||||
$output = $params['field']['data']['display_value_selected'];
|
||||
$output = wpcf_translate('field ' . $params['field']['id'] . ' checkbox value selected',
|
||||
$output);
|
||||
}
|
||||
} else if ($params['field']['data']['display'] == 'value') {
|
||||
if (!empty($params['field']['data']['display_value_not_selected'])) {
|
||||
$output = $params['field']['data']['display_value_not_selected'];
|
||||
$output = wpcf_translate('field ' . $params['field']['id'] . ' checkbox value not selected',
|
||||
$output);
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
@ -1,212 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Register data (called automatically).
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_checkboxes() {
|
||||
return array(
|
||||
'id' => 'wpcf-checkboxes',
|
||||
'title' => __('Checkboxes', 'wpcf'),
|
||||
'description' => __('Checkboxes', 'wpcf'),
|
||||
// 'validate' => array('required'),
|
||||
'meta_key_type' => 'BINARY',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Form data for post edit page.
|
||||
*
|
||||
* @param type $field
|
||||
*/
|
||||
function wpcf_fields_checkboxes_meta_box_form($field, $data) {
|
||||
$options = array();
|
||||
if (!empty($field['data']['options'])) {
|
||||
global $pagenow;
|
||||
foreach ($field['data']['options'] as $option_key => $option) {
|
||||
// Set value
|
||||
$options[$option_key] = array(
|
||||
'#value' => $option['set_value'],
|
||||
'#title' => wpcf_translate('field ' . $field['id'] . ' checkbox '
|
||||
. $option_key . ' title', $option['title']),
|
||||
'#default_value' => (!empty($data['#value'][$option_key])// Also check new post
|
||||
|| ($pagenow == 'post-new.php' && !empty($option['checked']))) ? 1 : 0,
|
||||
'#name' => 'wpcf[' . $field['id'] . '][' . $option_key . ']',
|
||||
'#id' => $option_key . '_' . mt_rand(),
|
||||
);
|
||||
}
|
||||
}
|
||||
return array(
|
||||
'#type' => 'checkboxes',
|
||||
'#options' => $options,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor callback form.
|
||||
*/
|
||||
function wpcf_fields_checkboxes_editor_callback() {
|
||||
$form = array();
|
||||
$form['#form']['callback'] = 'wpcf_fields_checkboxes_editor_submit';
|
||||
$form['display'] = array(
|
||||
'#type' => 'radios',
|
||||
'#default_value' => 'db',
|
||||
'#name' => 'display',
|
||||
'#options' => array(
|
||||
'display_from_db' => array(
|
||||
'#title' => __('Display the value of this field from the database',
|
||||
'wpcf'),
|
||||
'#name' => 'display',
|
||||
'#value' => 'db',
|
||||
'#inline' => true,
|
||||
'#after' => '<br />'
|
||||
),
|
||||
'display_values' => array(
|
||||
'#title' => __('Show one of these two values:', 'wpcf'),
|
||||
'#name' => 'display',
|
||||
'#value' => 'value',
|
||||
),
|
||||
),
|
||||
'#inline' => true,
|
||||
);
|
||||
if (isset($_GET['field_id'])) {
|
||||
$field = wpcf_admin_fields_get_field($_GET['field_id']);
|
||||
if (!empty($field['data']['options'])) {
|
||||
foreach ($field['data']['options'] as $option_key => $option) {
|
||||
$form[$option_key . '-markup'] = array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => '<h3>' . $option['title'] . '</h3>',
|
||||
);
|
||||
$form[$option_key . '-display-value-1'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => '<td style="text-align:right;">'
|
||||
. __('Not selected:', 'wpcf') . '</td><td>',
|
||||
'#name' => 'options[' . $option_key . '][display_value_not_selected]',
|
||||
'#value' => $option['display_value_not_selected'],
|
||||
'#inline' => true,
|
||||
'#before' => '<table><tr>',
|
||||
'#after' => '</td></tr>',
|
||||
);
|
||||
$form[$option_key . '-display-value-2'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => '<td style="text-align:right;">'
|
||||
. __('Selected:', 'wpcf') . '</td><td>',
|
||||
'#name' => 'options[' . $option_key . '][display_value_selected]',
|
||||
'#value' => $option['display_value_selected'],
|
||||
'#after' => '</tr></table>'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'submit',
|
||||
'#value' => __('Save Changes'),
|
||||
'#attributes' => array('class' => 'button-primary'),
|
||||
);
|
||||
$f = wpcf_form('wpcf-form', $form);
|
||||
wpcf_admin_ajax_head('Insert checkbox', 'wpcf');
|
||||
echo '<form method="post" action="">';
|
||||
echo $f->renderForm();
|
||||
echo '</form>';
|
||||
wpcf_admin_ajax_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor callback form submit.
|
||||
*/
|
||||
function wpcf_fields_checkboxes_editor_submit() {
|
||||
$add = '';
|
||||
$field = wpcf_admin_fields_get_field($_GET['field_id']);
|
||||
$shortcode = '';
|
||||
if (!empty($field)) {
|
||||
if (!empty($_POST['options'])) {
|
||||
$i = 0;
|
||||
foreach ($_POST['options'] as $option_key => $option) {
|
||||
if ($_POST['display'] == 'value') {
|
||||
|
||||
$shortcode .= '[types field="' . $field['slug'] . '" option="'
|
||||
. $i . '" state="checked"]'
|
||||
. $option['display_value_selected']
|
||||
. '[/types] ';
|
||||
$shortcode .= '[types field="' . $field['slug'] . '" option="'
|
||||
. $i . '" state="unchecked"]'
|
||||
. $option['display_value_not_selected']
|
||||
. '[/types] ';
|
||||
} else {
|
||||
$add = ' option="' . $i . '"';
|
||||
$shortcode .= wpcf_fields_get_shortcode($field, $add) . ' ';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
echo wpcf_admin_fields_popup_insert_shortcode_js($shortcode);
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* View function.
|
||||
*
|
||||
* @param type $params
|
||||
*/
|
||||
function wpcf_fields_checkboxes_view($params) {
|
||||
$option = array();
|
||||
if (!isset($params['option']) || empty($params['field']['data']['options'])) {
|
||||
return '__wpcf_skip_empty';
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
foreach ($params['field']['data']['options'] as $option_key => $option_value) {
|
||||
if (intval($params['option']) == $i) {
|
||||
$option['key'] = $option_key;
|
||||
$option['data'] = $option_value;
|
||||
$option['value'] = isset($params['field_value'][$option_key]) ? $params['field_value'][$option_key] : '__wpcf_unchecked';
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
$output = '';
|
||||
if (isset($params['state']) && $params['state'] == 'unchecked' && $option['value'] == '__wpcf_unchecked') {
|
||||
return htmlspecialchars_decode($params['#content']);
|
||||
} else if (isset($params['state']) && $params['state'] == 'unchecked') {
|
||||
return '__wpcf_skip_empty';
|
||||
}
|
||||
|
||||
if (isset($params['state']) && $params['state'] == 'checked' && $option['value'] != '__wpcf_unchecked') {
|
||||
return htmlspecialchars_decode($params['#content']);
|
||||
} else if (isset($params['state']) && $params['state'] == 'checked') {
|
||||
return '__wpcf_skip_empty';
|
||||
}
|
||||
// if (!empty($params['#content'])) {
|
||||
// return htmlspecialchars_decode($params['#content']);
|
||||
// }
|
||||
|
||||
if ($option['data']['display'] == 'db'
|
||||
&& !empty($option['data']['set_value']) && $option['value'] != '__wpcf_unchecked') {
|
||||
$output = $option['data']['set_value'];
|
||||
$output = wpcf_translate('field ' . $params['field']['id'] . ' checkbox value',
|
||||
$output);
|
||||
} else if ($option['data']['display'] == 'value'
|
||||
&& $option['value'] != '__wpcf_unchecked') {
|
||||
if (isset($option['data']['display_value_selected'])) {
|
||||
$output = $option['data']['display_value_selected'];
|
||||
$output = wpcf_translate('field ' . $params['field']['id'] . ' checkbox value selected',
|
||||
$output);
|
||||
}
|
||||
} else if ($option['data']['display'] == 'value') {
|
||||
if (isset($option['data']['display_value_not_selected'])) {
|
||||
$output = $option['data']['display_value_not_selected'];
|
||||
$output = wpcf_translate('field ' . $params['field']['id'] . ' checkbox value not selected',
|
||||
$output);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($output)) {
|
||||
return '__wpcf_skip_empty';
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
@ -1,554 +0,0 @@
|
||||
<?php
|
||||
global $supported_date_formats, $supported_date_formats_text;
|
||||
$supported_date_formats = array('F j, Y', //December 23, 2011
|
||||
'Y/m/d', // 2011/12/23
|
||||
'm/d/Y', // 12/23/2011
|
||||
'd/m/Y' // 23/22/2011
|
||||
);
|
||||
|
||||
$supported_date_formats_text = array('F j, Y' => 'Month dd, yyyy',
|
||||
'Y/m/d' => 'yyyy/mm/dd',
|
||||
'm/d/Y' => 'mm/dd/yyyy',
|
||||
'd/m/Y' => 'dd/mm/yyyy'
|
||||
);
|
||||
|
||||
function wpcf_get_date_format() {
|
||||
global $supported_date_formats;
|
||||
|
||||
$date_format = get_option('date_format');
|
||||
if (!in_array($date_format, $supported_date_formats)) {
|
||||
// Choose the Month day, Year fromat
|
||||
$date_format = 'F j, Y';
|
||||
}
|
||||
|
||||
return $date_format;
|
||||
}
|
||||
|
||||
function wpcf_get_date_format_text() {
|
||||
global $supported_date_formats, $supported_date_formats_text;
|
||||
|
||||
$date_format = get_option('date_format');
|
||||
if (!in_array($date_format, $supported_date_formats)) {
|
||||
// Choose the Month day, Year fromat
|
||||
$date_format = 'F j, Y';
|
||||
}
|
||||
|
||||
return $supported_date_formats_text[$date_format];
|
||||
}
|
||||
|
||||
add_filter('wpcf_fields_type_date_value_get',
|
||||
'wpcf_fields_date_value_get_filter');
|
||||
add_filter('wpcf_fields_type_date_value_save',
|
||||
'wpcf_fields_date_value_save_filter');
|
||||
|
||||
/**
|
||||
* Register data (called automatically).
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_date() {
|
||||
return array(
|
||||
'id' => 'wpcf-date',
|
||||
'title' => __('Date', 'wpcf'),
|
||||
'description' => __('Date', 'wpcf'),
|
||||
'validate' => array('required', 'date'),
|
||||
'meta_box_js' => array(
|
||||
'wpcf-jquery-fields-date' => array(
|
||||
'src' => WPCF_EMBEDDED_RES_RELPATH . '/js/jquery.ui.datepicker.min.js',
|
||||
'deps' => array('jquery-ui-core'),
|
||||
),
|
||||
'wpcf-jquery-fields-date-inline' => array(
|
||||
'inline' => 'wpcf_fields_date_meta_box_js_inline',
|
||||
),
|
||||
),
|
||||
'meta_box_css' => array(
|
||||
'wpcf-jquery-fields-date' => array(
|
||||
'src' => WPCF_EMBEDDED_RES_RELPATH . '/css/jquery-ui/datepicker.css',
|
||||
),
|
||||
),
|
||||
'inherited_field_type' => 'textfield',
|
||||
'meta_key_type' => 'TIME',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* From data for post edit page.
|
||||
*
|
||||
* @param type $field
|
||||
*/
|
||||
function wpcf_fields_date_meta_box_form($field) {
|
||||
if (isset($field['wpml_action']) && $field['wpml_action'] == 'copy') {
|
||||
$attributes = array('style' => 'width:150px;');
|
||||
} else {
|
||||
$attributes = array('class' => 'wpcf-datepicker', 'style' => 'width:150px;');
|
||||
}
|
||||
return array(
|
||||
'#type' => 'textfield',
|
||||
'#attributes' => $attributes,
|
||||
);
|
||||
}
|
||||
|
||||
function _wpcf_date_convert_wp_to_js($date_format) {
|
||||
$date_format = str_replace('d', 'dd', $date_format);
|
||||
$date_format = str_replace('j', 'd', $date_format);
|
||||
$date_format = str_replace('l', 'DD', $date_format);
|
||||
$date_format = str_replace('m', 'mm', $date_format);
|
||||
$date_format = str_replace('n', 'm', $date_format);
|
||||
$date_format = str_replace('F', 'MM', $date_format);
|
||||
$date_format = str_replace('Y', 'yy', $date_format);
|
||||
|
||||
return $date_format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders inline JS.
|
||||
*/
|
||||
function wpcf_fields_date_meta_box_js_inline() {
|
||||
|
||||
$date_format = wpcf_get_date_format();
|
||||
$date_format = _wpcf_date_convert_wp_to_js($date_format);
|
||||
|
||||
$date_format_note = '<span style="margin-left:10px"><i>' . esc_js(sprintf(__('Input format: %s',
|
||||
'wpcf'), wpcf_get_date_format_text())) . '</i></span>';
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
jQuery(document).ready(function(){
|
||||
wpcfFieldsDateInit('');
|
||||
});
|
||||
|
||||
function wpcfFieldsDateInit(div) {
|
||||
if (jQuery.isFunction(jQuery.fn.datepicker)) {
|
||||
jQuery(div+' .wpcf-datepicker').each(function(index) {
|
||||
if (!jQuery(this).is(':disabled') && !jQuery(this).hasClass('hasDatepicker')) {
|
||||
jQuery(this).datepicker({
|
||||
showOn: "button",
|
||||
buttonImage: "<?php echo WPCF_EMBEDDED_RES_RELPATH; ?>/images/calendar.gif",
|
||||
buttonImageOnly: true,
|
||||
buttonText: "<?php _e('Select date', 'wpcf'); ?>",
|
||||
dateFormat: "<?php echo $date_format; ?>",
|
||||
altFormat: "<?php echo $date_format; ?>"
|
||||
});
|
||||
jQuery(this).next().after('<?php echo $date_format_note; ?>');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function wpcfFieldsDateEditorCallback(field_id) {
|
||||
var url = "<?php echo admin_url('admin-ajax.php'); ?>?action=wpcf_ajax&wpcf_action=editor_insert_date&_wpnonce=<?php echo wp_create_nonce('fields_insert'); ?>&field_id="+field_id+"&keepThis=true&TB_iframe=true&width=400&height=400";
|
||||
tb_show("<?php _e('Insert date', 'wpcf'); ?>", url);
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts time to date on post edit page.
|
||||
*
|
||||
* @param type $value
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_date_value_get_filter($value) {
|
||||
if (empty($value)) {
|
||||
return $value;
|
||||
}
|
||||
return date(wpcf_get_date_format(), intval($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts date to time on post saving.
|
||||
*
|
||||
* @param type $value
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_date_value_save_filter($value) {
|
||||
if (empty($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
$date_format = wpcf_get_date_format();
|
||||
if ($date_format == 'd/m/Y') {
|
||||
// strtotime requires a dash or dot separator to determine dd/mm/yyyy format
|
||||
$value = str_replace('/', '-', $value);
|
||||
}
|
||||
return strtotime(strval($value));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Convert a format from date() to strftime() format
|
||||
*
|
||||
*/
|
||||
function wpcf_date_to_strftime($format) {
|
||||
|
||||
$format = str_replace('d', '%d', $format);
|
||||
$format = str_replace('D', '%a', $format);
|
||||
$format = str_replace('j', '%e', $format);
|
||||
$format = str_replace('l', '%A', $format);
|
||||
$format = str_replace('N', '%u', $format);
|
||||
$format = str_replace('w', '%w', $format);
|
||||
|
||||
$format = str_replace('W', '%W', $format);
|
||||
|
||||
$format = str_replace('F', '%B', $format);
|
||||
$format = str_replace('m', '%m', $format);
|
||||
$format = str_replace('M', '%b', $format);
|
||||
$format = str_replace('n', '%m', $format);
|
||||
|
||||
$format = str_replace('o', '%g', $format);
|
||||
$format = str_replace('Y', '%Y', $format);
|
||||
$format = str_replace('y', '%y', $format);
|
||||
|
||||
return $format;
|
||||
}
|
||||
|
||||
/**
|
||||
* View function.
|
||||
*
|
||||
* @param type $params
|
||||
*/
|
||||
function wpcf_fields_date_view($params) {
|
||||
|
||||
global $wp_locale;
|
||||
|
||||
$defaults = array(
|
||||
'format' => get_option('date_format'),
|
||||
);
|
||||
$params = wp_parse_args($params, $defaults);
|
||||
$output = '';
|
||||
switch ($params['style']) {
|
||||
case 'calendar':
|
||||
$output .= wpcf_fields_date_get_calendar($params, true, false);
|
||||
break;
|
||||
|
||||
default:
|
||||
$field_name = '';
|
||||
|
||||
|
||||
// Extract the Full month and Short month from the format.
|
||||
// We'll replace with the translated months if possible.
|
||||
$format = $params['format'];
|
||||
$format = str_replace('F', '#111111#', $format);
|
||||
$format = str_replace('M', '#222222#', $format);
|
||||
|
||||
// Same for the Days
|
||||
$format = str_replace('D', '#333333#', $format);
|
||||
$format = str_replace('l', '#444444#', $format);
|
||||
|
||||
$date_out = date($format, intval($params['field_value']));
|
||||
|
||||
$month = date('m', intval($params['field_value']));
|
||||
$month_full = $wp_locale->get_month($month);
|
||||
$date_out = str_replace('#111111#', $month_full, $date_out);
|
||||
$month_short = $wp_locale->get_month_abbrev($month_full);
|
||||
$date_out = str_replace('#222222#', $month_short, $date_out);
|
||||
|
||||
$day = date('w', intval($params['field_value']));
|
||||
$day_full = $wp_locale->get_weekday($day);
|
||||
$date_out = str_replace('#333333#', $day_full, $date_out);
|
||||
$day_short = $wp_locale->get_weekday_abbrev($day_full);
|
||||
$date_out = str_replace('#444444#', $day_short, $date_out);
|
||||
|
||||
$output = $date_out;
|
||||
break;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calendar view.
|
||||
*
|
||||
* @global type $wpdb
|
||||
* @global type $m
|
||||
* @global type $wp_locale
|
||||
* @global type $posts
|
||||
* @param type $params
|
||||
* @param type $initial
|
||||
* @param type $echo
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_date_get_calendar($params, $initial = true, $echo = true) {
|
||||
|
||||
global $wpdb, $m, $wp_locale, $posts;
|
||||
|
||||
// wpcf Set our own date
|
||||
$monthnum = date('n', $params['field_value']);
|
||||
$year = date('Y', $params['field_value']);
|
||||
$wpcf_date = date('j', $params['field_value']);
|
||||
|
||||
$cache = array();
|
||||
$key = md5($params['field']['slug'] . $wpcf_date);
|
||||
if ($cache = wp_cache_get('get_calendar', 'calendar')) {
|
||||
if (is_array($cache) && isset($cache[$key])) {
|
||||
if ($echo) {
|
||||
echo apply_filters('get_calendar', $cache[$key]);
|
||||
return;
|
||||
} else {
|
||||
return apply_filters('get_calendar', $cache[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_array($cache))
|
||||
$cache = array();
|
||||
|
||||
if (isset($_GET['w']))
|
||||
$w = '' . intval($_GET['w']);
|
||||
|
||||
// week_begins = 0 stands for Sunday
|
||||
$week_begins = intval(get_option('start_of_week'));
|
||||
|
||||
// Let's figure out when we are
|
||||
if (!empty($monthnum) && !empty($year)) {
|
||||
$thismonth = '' . zeroise(intval($monthnum), 2);
|
||||
$thisyear = '' . intval($year);
|
||||
} elseif (!empty($w)) {
|
||||
// We need to get the month from MySQL
|
||||
$thisyear = '' . intval(substr($m, 0, 4));
|
||||
$d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
|
||||
$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
|
||||
} elseif (!empty($m)) {
|
||||
$thisyear = '' . intval(substr($m, 0, 4));
|
||||
if (strlen($m) < 6)
|
||||
$thismonth = '01';
|
||||
else
|
||||
$thismonth = '' . zeroise(intval(substr($m, 4, 2)), 2);
|
||||
} else {
|
||||
$thisyear = gmdate('Y', current_time('timestamp'));
|
||||
$thismonth = gmdate('m', current_time('timestamp'));
|
||||
}
|
||||
|
||||
$unixmonth = mktime(0, 0, 0, $thismonth, 1, $thisyear);
|
||||
$last_day = date('t', $unixmonth);
|
||||
|
||||
/* translators: Calendar caption: 1: month name, 2: 4-digit year */
|
||||
$calendar_caption = _x('%1$s %2$s', 'calendar caption');
|
||||
$calendar_output = '<table id="wp-calendar" summary="' . esc_attr__('Calendar') . '">
|
||||
<caption>' . sprintf($calendar_caption,
|
||||
$wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
|
||||
<thead>
|
||||
<tr>';
|
||||
|
||||
$myweek = array();
|
||||
|
||||
for ($wdcount = 0; $wdcount <= 6; $wdcount++) {
|
||||
$myweek[] = $wp_locale->get_weekday(($wdcount + $week_begins) % 7);
|
||||
}
|
||||
|
||||
foreach ($myweek as $wd) {
|
||||
$day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
|
||||
$wd = esc_attr($wd);
|
||||
$calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
|
||||
}
|
||||
|
||||
$calendar_output .= '
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tfoot>
|
||||
<tr>';
|
||||
|
||||
$calendar_output .= '
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<tbody>
|
||||
<tr>';
|
||||
|
||||
// See how much we should pad in the beginning
|
||||
$pad = calendar_week_mod(date('w', $unixmonth) - $week_begins);
|
||||
if (0 != $pad)
|
||||
$calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr($pad) . '" class="pad"> </td>';
|
||||
|
||||
$daysinmonth = intval(date('t', $unixmonth));
|
||||
for ($day = 1; $day <= $daysinmonth; ++$day) {
|
||||
if (isset($newrow) && $newrow)
|
||||
$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
|
||||
$newrow = false;
|
||||
|
||||
if ($day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m',
|
||||
current_time('timestamp')) && $thisyear == gmdate('Y',
|
||||
current_time('timestamp')))
|
||||
$calendar_output .= '<td id="today">';
|
||||
else
|
||||
$calendar_output .= '<td>';
|
||||
|
||||
// wpcf
|
||||
if ($wpcf_date == $day) {
|
||||
$calendar_output .= '<a href="javascript:void(0);">' . $day . '</a>';
|
||||
} else {
|
||||
$calendar_output .= $day;
|
||||
}
|
||||
|
||||
$calendar_output .= '</td>';
|
||||
|
||||
if (6 == calendar_week_mod(date('w',
|
||||
mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins))
|
||||
$newrow = true;
|
||||
}
|
||||
|
||||
$pad = 7 - calendar_week_mod(date('w',
|
||||
mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins);
|
||||
if ($pad != 0 && $pad != 7)
|
||||
$calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr($pad) . '"> </td>';
|
||||
|
||||
$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
|
||||
|
||||
$cache[$key] = $calendar_output;
|
||||
wp_cache_set('get_calendar', $cache, 'calendar');
|
||||
|
||||
if ($echo)
|
||||
echo apply_filters('get_calendar', $calendar_output);
|
||||
else
|
||||
return apply_filters('get_calendar', $calendar_output);
|
||||
}
|
||||
|
||||
/**
|
||||
* TinyMCE editor form.
|
||||
*/
|
||||
function wpcf_fields_date_editor_callback() {
|
||||
$last_settings = wpcf_admin_fields_get_field_last_settings($_GET['field_id']);
|
||||
$form = array();
|
||||
$form['#form']['callback'] = 'wpcf_fields_date_editor_form_submit';
|
||||
$form['style'] = array(
|
||||
'#type' => 'radios',
|
||||
'#name' => 'wpcf[style]',
|
||||
'#options' => array(
|
||||
__('Show as calendar', 'wpcf') => 'calendar',
|
||||
__('Show as text', 'wpcf') => 'text',
|
||||
),
|
||||
'#default_value' => isset($last_settings['style']) ? $last_settings['style'] : 'text',
|
||||
'#after' => '<br />',
|
||||
);
|
||||
$date_formats = apply_filters('date_formats',
|
||||
array(
|
||||
__('F j, Y'),
|
||||
'Y/m/d',
|
||||
'm/d/Y',
|
||||
'd/m/Y',
|
||||
)
|
||||
);
|
||||
$options = array();
|
||||
foreach ($date_formats as $format) {
|
||||
$title = date($format, time());
|
||||
$field['#title'] = $title;
|
||||
$field['#value'] = $format;
|
||||
$options[] = $field;
|
||||
}
|
||||
$custom_format = isset($last_settings['format-custom']) ? $last_settings['format-custom'] : get_option('date_format');
|
||||
$options[] = array(
|
||||
'#title' => __('Custom', 'wpcf'),
|
||||
'#value' => 'custom',
|
||||
'#suffix' => wpcf_form_simple(array('custom' => array(
|
||||
'#name' => 'wpcf[format-custom]',
|
||||
'#type' => 'textfield',
|
||||
'#value' => $custom_format,
|
||||
'#suffix' => ' ' . date($custom_format, time()),
|
||||
'#inline' => true,
|
||||
))
|
||||
),
|
||||
);
|
||||
$form['toggle-open'] = array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => '<div id="wpcf-toggle" style="display:none;">',
|
||||
);
|
||||
$form['format'] = array(
|
||||
'#type' => 'radios',
|
||||
'#name' => 'wpcf[format]',
|
||||
'#options' => $options,
|
||||
'#default_value' => isset($last_settings['format']) ? $last_settings['format'] : get_option('date_format'),
|
||||
'#after' => '<a href="http://codex.wordpress.org/Formatting_Date_and_Time" target="_blank">'
|
||||
. __('Documentation on date and time formatting', 'wpcf') . '</a>',
|
||||
);
|
||||
$form['toggle-close'] = array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => '</div>',
|
||||
);
|
||||
$form['field_id'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#name' => 'wpcf[field_id]',
|
||||
'#value' => $_GET['field_id'],
|
||||
);
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'submit',
|
||||
'#value' => __('Insert date', 'wpcf'),
|
||||
'#attributes' => array('class' => 'button-primary'),
|
||||
);
|
||||
$f = wpcf_form('wpcf-fields-date-editor', $form);
|
||||
add_action('admin_head_wpcf_ajax', 'wpcf_fields_date_editor_form_script');
|
||||
wpcf_admin_ajax_head(__('Insert date', 'wpcf'));
|
||||
echo '<form id="wpcf-form" method="post" action="">';
|
||||
echo $f->renderForm();
|
||||
echo '</form>';
|
||||
wpcf_admin_ajax_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX window JS.
|
||||
*/
|
||||
function wpcf_fields_date_editor_form_script() {
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
// <![CDATA[
|
||||
jQuery(document).ready(function(){
|
||||
jQuery('input[name|="wpcf[style]"]').change(function(){
|
||||
if (jQuery(this).val() == 'text') {
|
||||
jQuery('#wpcf-toggle').slideDown();
|
||||
} else {
|
||||
jQuery('#wpcf-toggle').slideUp();
|
||||
}
|
||||
});
|
||||
if (jQuery('input:radio[name="wpcf[style]"]:checked').val() == 'text') {
|
||||
jQuery('#wpcf-toggle').show();
|
||||
}
|
||||
});
|
||||
// ]]>
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts shortcode in editor.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_date_editor_form_submit() {
|
||||
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
||||
if (!isset($_POST['wpcf']['field_id'])) {
|
||||
return false;
|
||||
}
|
||||
$field = wpcf_admin_fields_get_field($_POST['wpcf']['field_id']);
|
||||
if (empty($field)) {
|
||||
return false;
|
||||
}
|
||||
$add = ' ';
|
||||
$style = isset($_POST['wpcf']['style']) ? $_POST['wpcf']['style'] : 'text';
|
||||
$add .= 'style="' . $style . '"';
|
||||
$format = '';
|
||||
if ($style == 'text') {
|
||||
if ($_POST['wpcf']['format'] == 'custom') {
|
||||
$format = $_POST['wpcf']['format-custom'];
|
||||
} else {
|
||||
$format = $_POST['wpcf']['format'];
|
||||
}
|
||||
if (empty($format)) {
|
||||
$format = get_option('date_format');
|
||||
}
|
||||
$add .= ' format="' . $format . '"';
|
||||
}
|
||||
$shortcode = wpcf_fields_get_shortcode($field, $add);
|
||||
wpcf_admin_fields_save_field_last_settings($_POST['wpcf']['field_id'],
|
||||
array(
|
||||
'style' => $style,
|
||||
'format' => $_POST['wpcf']['format'],
|
||||
'format-custom' => $_POST['wpcf']['format-custom'],
|
||||
)
|
||||
);
|
||||
echo wpcf_admin_fields_popup_insert_shortcode_js($shortcode);
|
||||
die();
|
||||
}
|
||||
@ -1,127 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Register data (called automatically).
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_email() {
|
||||
return array(
|
||||
'id' => 'wpcf-email',
|
||||
'title' => __('Email', 'wpcf'),
|
||||
'description' => __('Email', 'wpcf'),
|
||||
'validate' => array('required', 'email'),
|
||||
'inherited_field_type' => 'textfield',
|
||||
'meta_box_js' => array(
|
||||
'wpcf-fields-email-inline' => array(
|
||||
'inline' => 'wpcf_fields_email_editor_callback_js',
|
||||
),
|
||||
),
|
||||
'editor_callback' => 'wpcfFieldsEmailEditorCallback(\'%s\')'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* View function.
|
||||
*
|
||||
* @param type $params
|
||||
*/
|
||||
function wpcf_fields_email_view($params) {
|
||||
$add = '';
|
||||
if (!empty($params['title'])) {
|
||||
$add .= ' title="' . $params['title'] . '"';
|
||||
$title = $params['title'];
|
||||
} else {
|
||||
$add .= ' title="' . $params['field_value'] . '"';
|
||||
$title = $params['field_value'];
|
||||
}
|
||||
if (!empty($params['class'])) {
|
||||
$add .= ' class="' . $params['class'] . '"';
|
||||
}
|
||||
if (!empty($params['style'])) {
|
||||
$add .= ' style="' . $params['style'] . '"';
|
||||
}
|
||||
$output = '<a href="mailto:' . $params['field_value'] . '"' . $add . '>'
|
||||
. $title . '</a>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor callback JS function
|
||||
*/
|
||||
function wpcf_fields_email_editor_callback_js() {
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function wpcfFieldsEmailEditorCallback(field_id) {
|
||||
var url = "<?php echo admin_url('admin-ajax.php'); ?>?action=wpcf_ajax&wpcf_action=editor_callback&field_id="+field_id+"&_wpnonce=<?php echo wp_create_nonce('editor_callback'); ?>&keepThis=true&TB_iframe=true&width=400&height=400";
|
||||
tb_show("<?php _e('Insert email',
|
||||
'wpcf'); ?>", url);
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor callback form.
|
||||
*/
|
||||
function wpcf_fields_email_editor_callback() {
|
||||
$last_settings = wpcf_admin_fields_get_field_last_settings($_GET['field_id']);
|
||||
$form = array();
|
||||
$form['#form']['callback'] = 'wpcf_fields_email_editor_submit';
|
||||
$form['title'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => __('Title', 'wpcf'),
|
||||
'#description' => __('If set, this text will be displayed instead of raw data'),
|
||||
'#name' => 'title',
|
||||
'#value' => isset($last_settings['title']) ? $last_settings['title'] : '',
|
||||
);
|
||||
$form['class'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => __('Class', 'wpcf'),
|
||||
'#name' => 'class',
|
||||
'#value' => isset($last_settings['class']) ? $last_settings['class'] : '',
|
||||
);
|
||||
$form['style'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => __('Style', 'wpcf'),
|
||||
'#name' => 'style',
|
||||
'#value' => isset($last_settings['style']) ? $last_settings['style'] : '',
|
||||
);
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'submit',
|
||||
'#value' => __('Save Changes'),
|
||||
'#attributes' => array('class' => 'button-primary'),
|
||||
);
|
||||
$f = wpcf_form('wpcf-form', $form);
|
||||
wpcf_admin_ajax_head('Insert email', 'wpcf');
|
||||
echo '<form method="post" action="">';
|
||||
echo $f->renderForm();
|
||||
echo '</form>';
|
||||
wpcf_admin_ajax_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor callback form submit.
|
||||
*/
|
||||
function wpcf_fields_email_editor_submit() {
|
||||
$add = '';
|
||||
if (!empty($_POST['title'])) {
|
||||
$add = ' title="' . strval($_POST['title']) . '"';
|
||||
}
|
||||
if (!empty($_POST['class'])) {
|
||||
$add .= ' class="' . $_POST['class'] . '"';
|
||||
}
|
||||
if (!empty($_POST['style'])) {
|
||||
$add .= ' style="' . $_POST['style'] . '"';
|
||||
}
|
||||
$field = wpcf_admin_fields_get_field($_GET['field_id']);
|
||||
if (!empty($field)) {
|
||||
$shortcode = wpcf_fields_get_shortcode($field, $add);
|
||||
wpcf_admin_fields_save_field_last_settings($_GET['field_id'], $_POST);
|
||||
echo wpcf_admin_fields_popup_insert_shortcode_js($shortcode);
|
||||
die();
|
||||
}
|
||||
}
|
||||
@ -1,314 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Register data (called automatically).
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_file() {
|
||||
return array(
|
||||
'id' => 'wpcf-file',
|
||||
'title' => __('File', 'wpcf'),
|
||||
'description' => __('File', 'wpcf'),
|
||||
'validate' => array('required'),
|
||||
'meta_box_js' => array(
|
||||
'wpcf-jquery-fields-file' => array(
|
||||
'inline' => 'wpcf_fields_file_meta_box_js_inline',
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Form data for post edit page.
|
||||
*
|
||||
* @param type $field
|
||||
*/
|
||||
function wpcf_fields_file_meta_box_form($field, $element, $image = false) {
|
||||
add_thickbox();
|
||||
$type = $field['type'] == 'image' ? 'image' : 'file';
|
||||
$button_text = $type == 'image' ? __('Upload image', 'wpcf') : __('Upload file',
|
||||
'wpcf');
|
||||
// Set ID
|
||||
$element_id = !empty($element['#id']) ? $element['#id'] : 'wpcf-fields-' . $field['slug'];
|
||||
$attachment_id = false;
|
||||
|
||||
// Get attachment by guid
|
||||
global $wpdb;
|
||||
if (!empty($field['value'])) {
|
||||
$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts}
|
||||
WHERE post_type = 'attachment' AND guid=%s",
|
||||
$field['value']));
|
||||
}
|
||||
|
||||
// Set preview
|
||||
$preview = '';
|
||||
if (!empty($attachment_id)) {
|
||||
$preview = wp_get_attachment_image($attachment_id, 'thumbnail');
|
||||
} else {
|
||||
// If external image set preview
|
||||
$file = pathinfo($field['value']);
|
||||
if (isset($file['extension'])
|
||||
&& in_array($file['extension'],
|
||||
array('jpg', 'jpeg', 'gif', 'png'))) {
|
||||
$preview = '<img alt="" src="' . $field['value'] . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
// Set button
|
||||
if (!empty($field['#attributes']['readonly']) || !empty($field['#attributes']['disabled'])) {
|
||||
$button = '';
|
||||
} else {
|
||||
$button = '<a href="javascript:void(0);"'
|
||||
. ' class="wpcf-fields-' . $type . '-upload-link button-secondary"'
|
||||
. ' id="' . $element_id . '-upload">'
|
||||
. $button_text . '</a>';
|
||||
}
|
||||
|
||||
// Set form
|
||||
$form = array(
|
||||
'#type' => 'textfield',
|
||||
'#id' => $element_id . '-upload-holder',
|
||||
'#name' => 'wpcf[' . $field['slug'] . ']',
|
||||
'#suffix' => ' ' . $button,
|
||||
'#after' => '<div id="' . $element_id
|
||||
. '-upload-holder-preview"'
|
||||
. ' class="wpcf-fields-file-preview">' . $preview . '</div>',
|
||||
'#attributes' => array('class' => 'wpcf-fields-file-textfield'),
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders inline JS.
|
||||
*/
|
||||
function wpcf_fields_file_meta_box_js_inline() {
|
||||
global $post;
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
jQuery(document).ready(function(){
|
||||
window.wpcf_formfield = false;
|
||||
jQuery('.wpcf-fields-file-upload-link').live('click', function() {
|
||||
window.wpcf_formfield = '#'+jQuery(this).attr('id')+'-holder';
|
||||
tb_show('<?php
|
||||
_e('Upload file', 'wpcf');
|
||||
|
||||
?>', 'media-upload.php?post_id=<?php echo $post->ID; ?>&type=file&wpcf-fields-media-insert=1&TB_iframe=true');
|
||||
return false;
|
||||
});
|
||||
});
|
||||
function wpcfFieldsFileMediaInsert(url, type) {
|
||||
jQuery(window.wpcf_formfield).val(url);
|
||||
if (type == 'image') {
|
||||
jQuery(window.wpcf_formfield+'-preview').html('<img src="'+url+'" />');
|
||||
} else {
|
||||
jQuery(window.wpcf_formfield+'-preview').html('');
|
||||
}
|
||||
tb_remove();
|
||||
window.wpcf_formfield = false;
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Media popup JS.
|
||||
*/
|
||||
function wpcf_fields_file_media_admin_head() {
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
function wpcfFieldsFileMediaTrigger(guid, type) {
|
||||
window.parent.wpcfFieldsFileMediaInsert(guid, type);
|
||||
window.parent.jQuery('#TB_closeWindowButton').trigger('click');
|
||||
}
|
||||
</script>
|
||||
<style type="text/css">
|
||||
tr.submit { display: none; }
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds 'Types' column to media item table.
|
||||
*
|
||||
* @param type $form_fields
|
||||
* @param type $post
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_file_attachment_fields_to_edit_filter($form_fields, $post) {
|
||||
$type = (strpos($post->post_mime_type, 'image/') !== false) ? 'image' : 'file';
|
||||
$form_fields['wpcf_fields_file'] = array(
|
||||
'label' => __('Types', 'wpcf'),
|
||||
'input' => 'html',
|
||||
'html' => '<a href="#" title="' . $post->guid
|
||||
. '" class="wpcf-fields-file-insert-button'
|
||||
. ' button-primary" onclick="wpcfFieldsFileMediaTrigger(\''
|
||||
. $post->guid . '\', \'' . $type . '\')">'
|
||||
. __('Use as field value', 'wpcf') . '</a><br /><br />',
|
||||
// 'helps' => __('Set this file as file value', 'wpcf'),
|
||||
);
|
||||
return $form_fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* View function.
|
||||
*
|
||||
* @param type $params
|
||||
*/
|
||||
function wpcf_fields_file_view($params) {
|
||||
$output = '';
|
||||
if (isset($params['link']) && $params['link'] == 'true') {
|
||||
$title = '';
|
||||
$add = '';
|
||||
if (!empty($params['title'])) {
|
||||
$add .= ' title="' . $params['title'] . '"';
|
||||
$title .= $params['title'];
|
||||
} else {
|
||||
$add .= ' title="' . $params['field_value'] . '"';
|
||||
$title .= $params['field_value'];
|
||||
}
|
||||
if (!empty($params['class'])) {
|
||||
$add .= ' class="' . $params['class'] . '"';
|
||||
}
|
||||
if (!empty($params['style'])) {
|
||||
$add .= ' style="' . $params['style'] . '"';
|
||||
}
|
||||
$output = '<a href="' . $params['field_value'] . '"' . $add . '>'
|
||||
. $title . '</a>';
|
||||
} else {
|
||||
$output = $params['field_value'];
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor callback form.
|
||||
*/
|
||||
function wpcf_fields_file_editor_callback() {
|
||||
wp_enqueue_style('wpcf-fields-file',
|
||||
WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION);
|
||||
|
||||
// Get field
|
||||
$field = wpcf_admin_fields_get_field($_GET['field_id']);
|
||||
if (empty($field)) {
|
||||
_e('Wrong field specified', 'wpcf');
|
||||
die();
|
||||
}
|
||||
|
||||
// Get post_ID
|
||||
$post_ID = false;
|
||||
if (isset($_POST['post_id'])) {
|
||||
$post_ID = intval($_POST['post_id']);
|
||||
} else {
|
||||
$http_referer = explode('?', $_SERVER['HTTP_REFERER']);
|
||||
parse_str($http_referer[1], $http_referer);
|
||||
if (isset($http_referer['post'])) {
|
||||
$post_ID = $http_referer['post'];
|
||||
}
|
||||
}
|
||||
|
||||
// Get attachment
|
||||
$attachment_id = false;
|
||||
if ($post_ID) {
|
||||
$file = get_post_meta($post_ID,
|
||||
wpcf_types_get_meta_prefix($field) . $field['slug'], true);
|
||||
if (!empty($file)) {
|
||||
// Get attachment by guid
|
||||
global $wpdb;
|
||||
$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts}
|
||||
WHERE post_type = 'attachment' AND guid=%s",
|
||||
$file));
|
||||
}
|
||||
}
|
||||
|
||||
$last_settings = wpcf_admin_fields_get_field_last_settings($_GET['field_id']);
|
||||
|
||||
$form = array();
|
||||
$form['#form']['callback'] = 'wpcf_fields_file_editor_submit';
|
||||
if ($attachment_id) {
|
||||
$form['preview'] = array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => '<div class="message updated" style="margin: 0 0 20px 0"><p>'
|
||||
. $file . '</p></div>',
|
||||
);
|
||||
}
|
||||
$form['link'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => __('Display as link', 'wpcf'),
|
||||
'#name' => 'link',
|
||||
'#default_value' => isset($last_settings['link']) ? $last_settings['link'] : 1,
|
||||
);
|
||||
$form['title'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => __('Link title', 'wpcf'),
|
||||
'#name' => 'title',
|
||||
'#value' => isset($last_settings['title']) ? $last_settings['title'] : '',
|
||||
);
|
||||
$form['class'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => __('Class', 'wpcf'),
|
||||
'#name' => 'class',
|
||||
'#value' => isset($last_settings['class']) ? $last_settings['class'] : '',
|
||||
);
|
||||
$form['style'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => __('Style', 'wpcf'),
|
||||
'#name' => 'style',
|
||||
'#value' => isset($last_settings['style']) ? $last_settings['style'] : '',
|
||||
);
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'submit',
|
||||
'#value' => __('Insert shortcode', 'wpcf'),
|
||||
'#attributes' => array('class' => 'button-primary'),
|
||||
);
|
||||
$f = wpcf_form('wpcf-form', $form);
|
||||
wpcf_admin_ajax_head('Insert email', 'wpcf');
|
||||
echo '<form method="post" action="">';
|
||||
echo $f->renderForm();
|
||||
echo '</form>';
|
||||
wpcf_admin_ajax_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor callback form submit.
|
||||
*/
|
||||
function wpcf_fields_file_editor_submit() {
|
||||
$add = '';
|
||||
if (!empty($_POST['link'])) {
|
||||
$add .= ' link="true"';
|
||||
if (!empty($_POST['title'])) {
|
||||
$add .= ' title="' . strval($_POST['title']) . '"';
|
||||
}
|
||||
}
|
||||
if (!empty($_POST['class'])) {
|
||||
$add .= ' class="' . $_POST['class'] . '"';
|
||||
}
|
||||
if (!empty($_POST['style'])) {
|
||||
$add .= ' style="' . $_POST['style'] . '"';
|
||||
}
|
||||
$field = wpcf_admin_fields_get_field($_GET['field_id']);
|
||||
if (!empty($field)) {
|
||||
$shortcode = wpcf_fields_get_shortcode($field, $add);
|
||||
wpcf_admin_fields_save_field_last_settings($_GET['field_id'], $_POST);
|
||||
echo wpcf_admin_fields_popup_insert_shortcode_js($shortcode);
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters media TABs.
|
||||
*
|
||||
* @param type $tabs
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_file_media_upload_tabs_filter($tabs) {
|
||||
unset($tabs['type_url']);
|
||||
return $tabs;
|
||||
}
|
||||
@ -1,724 +0,0 @@
|
||||
<?php
|
||||
add_filter('wpcf_fields_type_image_value_get', 'wpcf_fields_image_value_filter');
|
||||
add_filter('wpcf_fields_type_image_value_save', 'wpcf_fields_image_value_filter');
|
||||
|
||||
/**
|
||||
* Register data (called automatically).
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_image() {
|
||||
return array(
|
||||
'id' => 'wpcf-image',
|
||||
'title' => __('Image', 'wpcf'),
|
||||
'description' => __('Image', 'wpcf'),
|
||||
'validate' => array('required'),
|
||||
'meta_box_js' => array(
|
||||
'wpcf-jquery-fields-file' => array(
|
||||
'inline' => 'wpcf_fields_file_meta_box_js_inline',
|
||||
),
|
||||
'wpcf-jquery-fields-image' => array(
|
||||
'inline' => 'wpcf_fields_image_meta_box_js_inline',
|
||||
),
|
||||
),
|
||||
'inherited_field_type' => 'file',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders inline JS.
|
||||
*/
|
||||
function wpcf_fields_image_meta_box_js_inline() {
|
||||
global $post;
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
jQuery(document).ready(function(){
|
||||
wpcf_formfield = false;
|
||||
jQuery('.wpcf-fields-image-upload-link').live('click', function() {
|
||||
wpcf_formfield = '#'+jQuery(this).attr('id')+'-holder';
|
||||
tb_show('<?php
|
||||
echo esc_js(__('Upload image', 'wpcf'));
|
||||
|
||||
?>', 'media-upload.php?post_id=<?php echo $post->ID; ?>&type=image&wpcf-fields-media-insert=1&TB_iframe=true');
|
||||
return false;
|
||||
});
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor callback form.
|
||||
*/
|
||||
function wpcf_fields_image_editor_callback() {
|
||||
wp_enqueue_style('wpcf-fields-image',
|
||||
WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION);
|
||||
wp_enqueue_script('jquery');
|
||||
|
||||
// Get field
|
||||
$field = wpcf_admin_fields_get_field($_GET['field_id']);
|
||||
if (empty($field)) {
|
||||
_e('Wrong field specified', 'wpcf');
|
||||
die();
|
||||
}
|
||||
|
||||
// Get post_ID
|
||||
$post_ID = false;
|
||||
if (isset($_POST['post_id'])) {
|
||||
$post_ID = intval($_POST['post_id']);
|
||||
} else {
|
||||
$http_referer = explode('?', $_SERVER['HTTP_REFERER']);
|
||||
if (isset($http_referer[1])) {
|
||||
parse_str($http_referer[1], $http_referer);
|
||||
if (isset($http_referer['post'])) {
|
||||
$post_ID = $http_referer['post'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get attachment
|
||||
$image = false;
|
||||
$attachment_id = false;
|
||||
if ($post_ID) {
|
||||
$image = get_post_meta($post_ID,
|
||||
wpcf_types_get_meta_prefix($field) . $field['slug'], true);
|
||||
if (!empty($image)) {
|
||||
// Get attachment by guid
|
||||
global $wpdb;
|
||||
$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts}
|
||||
WHERE post_type = 'attachment' AND guid=%s",
|
||||
$image));
|
||||
}
|
||||
}
|
||||
|
||||
// Get post type
|
||||
$post_type = '';
|
||||
if ($post_ID) {
|
||||
$post_type = get_post_type($post_ID);
|
||||
} else {
|
||||
$http_referer = explode('?', $_SERVER['HTTP_REFERER']);
|
||||
parse_str($http_referer[1], $http_referer);
|
||||
if (isset($http_referer['post_type'])) {
|
||||
$post_type = $http_referer['post_type'];
|
||||
}
|
||||
}
|
||||
|
||||
$image_data = wpcf_fields_image_get_data($image);
|
||||
|
||||
if (!in_array($post_type, array('view', 'view-template'))) {
|
||||
// We must ignore errors here and treat image as outsider
|
||||
if (!empty($image_data['error'])) {
|
||||
$image_data['is_outsider'] = 1;
|
||||
$image_data['is_attachment'] = 0;
|
||||
}
|
||||
} else {
|
||||
if (!empty($image_data['error'])) {
|
||||
$image_data['is_outsider'] = 0;
|
||||
$image_data['is_attachment'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$last_settings = wpcf_admin_fields_get_field_last_settings($_GET['field_id']);
|
||||
|
||||
$form = array();
|
||||
$form['#form']['callback'] = 'wpcf_fields_image_editor_submit';
|
||||
if ($attachment_id) {
|
||||
$form['preview'] = array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => '<div style="position:absolute; margin-left:300px;">'
|
||||
. wp_get_attachment_image($attachment_id, 'thumbnail') . '</div>',
|
||||
);
|
||||
}
|
||||
$alt = '';
|
||||
$title = '';
|
||||
if ($attachment_id) {
|
||||
$alt = trim(strip_tags(get_post_meta($attachment_id,
|
||||
'_wp_attachment_image_alt', true)));
|
||||
$attachment_post = get_post($attachment_id);
|
||||
if (!empty($attachment_post)) {
|
||||
$title = trim(strip_tags($attachment_post->post_title));
|
||||
} else if (!empty($alt)) {
|
||||
$title = $alt;
|
||||
}
|
||||
if (empty($alt)) {
|
||||
$alt = $title;
|
||||
}
|
||||
}
|
||||
$form['title'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => __('Image title', 'wpcf'),
|
||||
'#description' => __('Title text for the image, e.g. “The Mona Lisa”',
|
||||
'wpcf'),
|
||||
'#name' => 'title',
|
||||
'#value' => isset($last_settings['title']) ? $last_settings['title'] : $title,
|
||||
);
|
||||
$form['alt'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => __('Alternate Text', 'wpcf'),
|
||||
'#description' => __('Alt text for the image, e.g. “The Mona Lisa”',
|
||||
'wpcf'),
|
||||
'#name' => 'alt',
|
||||
'#value' => isset($last_settings['alt']) ? $last_settings['alt'] : $alt,
|
||||
);
|
||||
$form['alignment'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => __('Alignment', 'wpcf'),
|
||||
'#name' => 'alignment',
|
||||
'#default_value' => isset($last_settings['alignment']) ? $last_settings['alignment'] : 'none',
|
||||
'#options' => array(
|
||||
__('None', 'wpcf') => 'none',
|
||||
__('Left', 'wpcf') => 'left',
|
||||
__('Center', 'wpcf') => 'center',
|
||||
__('Right', 'wpcf') => 'right',
|
||||
),
|
||||
);
|
||||
$form['class'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => __('Class', 'wpcf'),
|
||||
'#name' => 'class',
|
||||
'#value' => isset($last_settings['class']) ? $last_settings['class'] : '',
|
||||
);
|
||||
$form['style'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => __('Style', 'wpcf'),
|
||||
'#name' => 'style',
|
||||
'#value' => isset($last_settings['style']) ? $last_settings['style'] : '',
|
||||
);
|
||||
|
||||
if (!in_array($post_type, array('view', 'view-template'))) {
|
||||
$attributes_outsider = $image_data['is_outsider'] ? array('disabled' => 'disabled') : array();
|
||||
$attributes_attachment = !$image_data['is_attachment'] ? array('disabled' => 'disabled') : array();
|
||||
} else {
|
||||
$attributes_outsider = array();
|
||||
$attributes_attachment = array();
|
||||
}
|
||||
|
||||
if (!in_array($post_type, array('view', 'view-template')) && $image_data['is_outsider']) {
|
||||
$form['notice'] = array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => '<div class="message error" style="margin:0 0 20px 0;"><p>'
|
||||
. __('Types can only resize images that you upload to this site and not images from other domains.',
|
||||
'wpcf')
|
||||
. '</p></div>',
|
||||
);
|
||||
} else if ($image_data['is_outsider']) {
|
||||
$form['notice'] = array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => '<div class="message error" style="margin:0 0 20px 0;"><p>'
|
||||
. __('Types will be able to resize images that are uploaded to the post. If you specify URLs of images on other sites, Types will not resize them.',
|
||||
'wpcf')
|
||||
. '</p></div>',
|
||||
);
|
||||
}
|
||||
if ($image_data['is_attachment']) {
|
||||
$default_value = isset($last_settings['image-size']) ? $last_settings['image-size'] : 'thumbnail';
|
||||
} else if (!$image_data['is_outsider']) {
|
||||
$default_value = 'wpcf-custom';
|
||||
} else {
|
||||
$default_value = 'thumbnail';
|
||||
}
|
||||
$form['size'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => __('Pre-defined sizes', 'wpcf'),
|
||||
'#name' => 'image-size',
|
||||
'#default_value' => $default_value,
|
||||
'#options' => array(
|
||||
'thumbnail' => array('#title' => __('Thumbnail', 'wpcf'), '#value' => 'thumbnail', '#attributes' => $attributes_attachment),
|
||||
'medium' => array('#title' => __('Medium', 'wpcf'), '#value' => 'medium', '#attributes' => $attributes_attachment),
|
||||
'large' => array('#title' => __('Large', 'wpcf'), '#value' => 'large', '#attributes' => $attributes_attachment),
|
||||
'full' => array('#title' => __('Full Size', 'wpcf'), '#value' => 'full', '#attributes' => $attributes_attachment),
|
||||
'wpcf-custom' => array('#title' => __('Custom size', 'wpcf'), '#value' => 'wpcf-custom', '#attributes' => $attributes_outsider),
|
||||
),
|
||||
);
|
||||
$form['toggle-open'] = array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => '<div id="wpcf-toggle" style="display:none;">',
|
||||
);
|
||||
$form['width'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => __('Width', 'wpcf'),
|
||||
'#description' => __('Specify custom width', 'wpcf'),
|
||||
'#name' => 'width',
|
||||
'#value' => isset($last_settings['width']) ? $last_settings['width'] : '',
|
||||
'#suffix' => ' px',
|
||||
'#attributes' => $attributes_outsider,
|
||||
);
|
||||
$form['height'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => __('Height', 'wpcf'),
|
||||
'#description' => __('Specify custom height', 'wpcf'),
|
||||
'#name' => 'height',
|
||||
'#value' => isset($last_settings['height']) ? $last_settings['height'] : '',
|
||||
'#suffix' => ' px',
|
||||
'#attributes' => $attributes_outsider,
|
||||
);
|
||||
$form['proportional'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => __('Keep proportional', 'wpcf'),
|
||||
'#name' => 'proportional',
|
||||
'#default_value' => 1,
|
||||
'#attributes' => $attributes_outsider,
|
||||
);
|
||||
$form['toggle-close'] = array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => '</div>',
|
||||
'#attributes' => $attributes_outsider,
|
||||
);
|
||||
if ($post_ID) {
|
||||
$form['post_id'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#name' => 'post_id',
|
||||
'#value' => $post_ID,
|
||||
);
|
||||
}
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'submit',
|
||||
'#value' => __('Insert shortcode', 'wpcf'),
|
||||
'#attributes' => array('class' => 'button-primary'),
|
||||
);
|
||||
$f = wpcf_form('wpcf-form', $form);
|
||||
wpcf_admin_ajax_head('Insert email', 'wpcf');
|
||||
echo '<form method="post" action="">';
|
||||
echo $f->renderForm();
|
||||
echo '</form>';
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
jQuery(document).ready(function(){
|
||||
jQuery('input:radio[name="image-size"]').change(function(){
|
||||
if (jQuery(this).val() == 'wpcf-custom') {
|
||||
jQuery('#wpcf-toggle').slideDown();
|
||||
} else {
|
||||
jQuery('#wpcf-toggle').slideUp();
|
||||
}
|
||||
});
|
||||
if (jQuery('input:radio[name="image-size"]:checked').val() == 'wpcf-custom') {
|
||||
jQuery('#wpcf-toggle').show();
|
||||
}
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
wpcf_admin_ajax_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor callback form submit.
|
||||
*/
|
||||
function wpcf_fields_image_editor_submit() {
|
||||
$add = '';
|
||||
if (!empty($_POST['alt'])) {
|
||||
$add .= ' alt="' . strval($_POST['alt']) . '"';
|
||||
}
|
||||
if (!empty($_POST['title'])) {
|
||||
$add .= ' title="' . strval($_POST['title']) . '"';
|
||||
}
|
||||
$size = !empty($_POST['image-size']) ? $_POST['image-size'] : false;
|
||||
if ($size == 'wpcf-custom') {
|
||||
if (!empty($_POST['width'])) {
|
||||
$add .= ' width="' . intval($_POST['width']) . '"';
|
||||
}
|
||||
if (!empty($_POST['height'])) {
|
||||
$add .= ' height="' . intval($_POST['height']) . '"';
|
||||
}
|
||||
if (!empty($_POST['proportional'])) {
|
||||
$add .= ' proportional="true"';
|
||||
}
|
||||
} else if (!empty($size)) {
|
||||
$add .= ' size="' . $size . '"';
|
||||
}
|
||||
if (!empty($_POST['alignment'])) {
|
||||
$add .= ' align="' . $_POST['alignment'] . '"';
|
||||
}
|
||||
if (!empty($_POST['class'])) {
|
||||
$add .= ' class="' . $_POST['class'] . '"';
|
||||
}
|
||||
if (!empty($_POST['style'])) {
|
||||
$add .= ' style="' . $_POST['style'] . '"';
|
||||
}
|
||||
$field = wpcf_admin_fields_get_field($_GET['field_id']);
|
||||
if (!empty($field)) {
|
||||
$shortcode = wpcf_fields_get_shortcode($field, $add);
|
||||
wpcf_admin_fields_save_field_last_settings($_GET['field_id'], $_POST);
|
||||
echo wpcf_admin_fields_popup_insert_shortcode_js($shortcode);
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* View function.
|
||||
*
|
||||
* @param type $params
|
||||
*/
|
||||
function wpcf_fields_image_view($params) {
|
||||
$output = '';
|
||||
$alt = false;
|
||||
$title = false;
|
||||
$class = array();
|
||||
$style = array();
|
||||
|
||||
// Get image data
|
||||
$image_data = wpcf_fields_image_get_data($params['field_value']);
|
||||
|
||||
// Display error to admin only
|
||||
if (!empty($image_data['error'])) {
|
||||
if (current_user_can('administrator')) {
|
||||
return '<div style="padding:10px;background-color:Red;color:#FFFFFF;">'
|
||||
. 'Types: ' . $image_data['error'] . '</div>';
|
||||
}
|
||||
return $params['field_value'];
|
||||
}
|
||||
|
||||
// Set alt
|
||||
if (isset($params['alt'])) {
|
||||
$alt = $params['alt'];
|
||||
}
|
||||
|
||||
// Set title
|
||||
if (isset($params['title'])) {
|
||||
$title = $params['title'];
|
||||
}
|
||||
|
||||
// Set attachment class
|
||||
if (!empty($params['size'])) {
|
||||
$class[] = 'attachment-' . $params['size'];
|
||||
}
|
||||
|
||||
// Set align class
|
||||
if (!empty($params['align']) && $params['align'] != 'none') {
|
||||
$class[] = 'align' . $params['align'];
|
||||
}
|
||||
|
||||
if (!empty($params['class'])) {
|
||||
$class[] = $params['class'];
|
||||
}
|
||||
if (!empty($params['style'])) {
|
||||
$style[] = $params['style'];
|
||||
}
|
||||
|
||||
// Pre-configured size (use WP function)
|
||||
if ($image_data['is_attachment'] && !empty($params['size'])) {
|
||||
if (isset($params['url']) && $params['url'] == 'true') {
|
||||
$image_url = wp_get_attachment_image_src($image_data['is_attachment'],
|
||||
$params['size']);
|
||||
if (!empty($image_url[0])) {
|
||||
$output = $image_url[0];
|
||||
} else {
|
||||
$output = $params['field_value'];
|
||||
}
|
||||
} else {
|
||||
$output = wp_get_attachment_image($image_data['is_attachment'],
|
||||
$params['size'], false,
|
||||
array(
|
||||
'class' => implode(' ', $class),
|
||||
'style' => implode(' ', $style),
|
||||
'alt' => $alt,
|
||||
'title' => $title
|
||||
)
|
||||
);
|
||||
}
|
||||
} else { // Custom size
|
||||
$width = !empty($params['width']) ? intval($params['width']) : null;
|
||||
$height = !empty($params['height']) ? intval($params['height']) : null;
|
||||
$crop = (!empty($params['proportional']) && $params['proportional'] == 'true') ? false : true;
|
||||
|
||||
// Check if image is outsider
|
||||
if (!$image_data['is_outsider']) {
|
||||
$resized_image = wpcf_fields_image_resize_image(
|
||||
$params['field_value'], $width, $height, 'relpath', false,
|
||||
$crop
|
||||
);
|
||||
if (!$resized_image) {
|
||||
$resized_image = $params['field_value'];
|
||||
} else {
|
||||
// Add to library
|
||||
$image_abspath = wpcf_fields_image_resize_image(
|
||||
$params['field_value'], $width, $height, 'abspath',
|
||||
false, $crop
|
||||
);
|
||||
$add_to_library = wpcf_get_settings('add_resized_images_to_library');
|
||||
if ($add_to_library) {
|
||||
global $wpdb;
|
||||
$attachment_exists = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts}
|
||||
WHERE post_type = 'attachment' AND guid=%s",
|
||||
$resized_image));
|
||||
if (empty($attachment_exists)) {
|
||||
// Add as attachment
|
||||
$wp_filetype = wp_check_filetype(basename($image_abspath),
|
||||
null);
|
||||
$attachment = array(
|
||||
'post_mime_type' => $wp_filetype['type'],
|
||||
'post_title' => preg_replace('/\.[^.]+$/', '',
|
||||
basename($image_abspath)),
|
||||
'post_content' => '',
|
||||
'post_status' => 'inherit',
|
||||
'guid' => $resized_image,
|
||||
);
|
||||
global $post;
|
||||
$attach_id = wp_insert_attachment($attachment,
|
||||
$image_abspath, $post->ID);
|
||||
// you must first include the image.php file
|
||||
// for the function wp_generate_attachment_metadata() to work
|
||||
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
|
||||
$attach_data = wp_generate_attachment_metadata($attach_id,
|
||||
$image_abspath);
|
||||
wp_update_attachment_metadata($attach_id, $attach_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$resized_image = $params['field_value'];
|
||||
}
|
||||
if (isset($params['url']) && $params['url'] == 'true') {
|
||||
return $resized_image;
|
||||
}
|
||||
$output = '<img alt="';
|
||||
$output .= $alt !== false ? $alt : $resized_image;
|
||||
$output .= '" title="';
|
||||
$output .= $title !== false ? $title : $resized_image;
|
||||
$output .= '"';
|
||||
$output .=!empty($params['onload']) ? ' onload="' . $params['onload'] . '"' : '';
|
||||
$output .=!empty($class) ? ' class="' . implode(' ', $class) . '"' : '';
|
||||
$output .=!empty($style) ? ' style="' . implode(' ', $style) . '"' : '';
|
||||
$output .= ' src="' . $resized_image . '" />';
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resizes image using WP image_resize() function.
|
||||
*
|
||||
* Caches return data if called more than one time in one pass.
|
||||
*
|
||||
* @staticvar array $cached Caches calls in one pass
|
||||
* @param <type> $url_path Full URL path (works only with images on same domain)
|
||||
* @param <type> $width
|
||||
* @param <type> $height
|
||||
* @param <type> $refresh Set to true if you want image re-created or not cached
|
||||
* @param <type> $crop Set to true if you want apspect ratio to be preserved
|
||||
* @param string $suffix Optional (default 'wpcf_$widthxheight)
|
||||
* @param <type> $dest_path Optional (defaults to original image)
|
||||
* @param <type> $quality
|
||||
* @return array
|
||||
*/
|
||||
function wpcf_fields_image_resize_image($url_path, $width = 300, $height = 200,
|
||||
$return = 'relpath', $refresh = FALSE, $crop = TRUE, $suffix = '',
|
||||
$dest_path = NULL, $quality = 75) {
|
||||
|
||||
if (empty($url_path)) {
|
||||
return $url_path;
|
||||
}
|
||||
|
||||
// Get image data
|
||||
$image_data = wpcf_fields_image_get_data($url_path);
|
||||
|
||||
if (empty($image_data['fullabspath']) || !empty($image_data['error'])) {
|
||||
return $url_path;
|
||||
}
|
||||
|
||||
// Set cache
|
||||
static $cached = array();
|
||||
$cache_key = md5($url_path . $width . $height . intval($crop) . $suffix . $dest_path);
|
||||
|
||||
// Check if cached in this call
|
||||
if (!$refresh && isset($cached[$cache_key][$return])) {
|
||||
return $cached[$cache_key][$return];
|
||||
}
|
||||
|
||||
$width = intval($width);
|
||||
$height = intval($height);
|
||||
|
||||
// Get size of new file
|
||||
$size = @getimagesize($image_data['fullabspath']);
|
||||
if (!$size) {
|
||||
return $url_path;
|
||||
}
|
||||
list($orig_w, $orig_h, $orig_type) = $size;
|
||||
$dims = image_resize_dimensions($orig_w, $orig_h, $width, $height, $crop);
|
||||
if (!$dims) {
|
||||
return $url_path;
|
||||
}
|
||||
list($dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) = $dims;
|
||||
|
||||
// Set suffix
|
||||
if (empty($suffix)) {
|
||||
$suffix = 'wpcf_' . $dst_w . 'x' . $dst_h;
|
||||
} else {
|
||||
$suffix .= '_wpcf_' . $dst_w . 'x' . $dst_h;
|
||||
}
|
||||
|
||||
$image_data['extension'] = in_array($image_data['extension'],
|
||||
array('gif', 'png')) ? $image_data['extension'] : 'jpg';
|
||||
|
||||
$image_relpath = $image_data['relpath'] . '/' . $image_data['image_name'] . '-'
|
||||
. $suffix . '.' . $image_data['extension'];
|
||||
$image_abspath = $image_data['abspath'] . DIRECTORY_SEPARATOR
|
||||
. $image_data['image_name'] . '-' . $suffix . '.'
|
||||
. $image_data['extension'];
|
||||
|
||||
// Check if already resized
|
||||
if (!$refresh && file_exists($image_abspath)) {
|
||||
// Cache it
|
||||
$cached[$cache_key]['relpath'] = $image_relpath;
|
||||
$cached[$cache_key]['abspath'] = $image_abspath;
|
||||
return $return == 'relpath' ? $image_relpath : $image_abspath;
|
||||
}
|
||||
|
||||
// If original file don't exists
|
||||
if (!file_exists($image_data['fullabspath'])) {
|
||||
return $url_path;
|
||||
}
|
||||
|
||||
// Resize image
|
||||
$resized_image = @image_resize(
|
||||
$image_data['fullabspath'], $width, $height, $crop, $suffix,
|
||||
$dest_path, $quality
|
||||
);
|
||||
|
||||
// Check if error
|
||||
if (is_wp_error($resized_image)) {
|
||||
return $url_path;
|
||||
}
|
||||
|
||||
$image_abspath = $resized_image;
|
||||
|
||||
// Cache it
|
||||
$cached[$cache_key]['relpath'] = $image_relpath;
|
||||
$cached[$cache_key]['abspath'] = $image_abspath;
|
||||
|
||||
return $return == 'relpath' ? $image_relpath : $image_abspath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all necessary data for processed image.
|
||||
*
|
||||
* @global type $wpdb
|
||||
* @param type $image
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_image_get_data($image) {
|
||||
|
||||
// Check if already cached
|
||||
static $cache = array();
|
||||
if (isset($cache[md5($image)])) {
|
||||
return $cache[md5($image)];
|
||||
}
|
||||
|
||||
// Strip GET vars
|
||||
$image = strtok($image, '?');
|
||||
|
||||
// Basic URL check
|
||||
if (strpos($image, 'http') != 0) {
|
||||
return array('error' => sprintf(__('Image %s not valid', 'wpcf'), $image));
|
||||
}
|
||||
// Extension check
|
||||
$extension = pathinfo($image, PATHINFO_EXTENSION);
|
||||
if (!in_array($extension, array('jpg', 'jpeg', 'gif', 'png'))) {
|
||||
return array('error' => sprintf(__('Image %s not valid', 'wpcf'), $image));
|
||||
}
|
||||
|
||||
// Defaults
|
||||
$abspath = '';
|
||||
$relpath = '';
|
||||
$is_outsider = 1;
|
||||
$is_in_upload_path = 0;
|
||||
$is_attachment = 0;
|
||||
$error = '';
|
||||
|
||||
// Check if it's on domain or subdomain
|
||||
$url = get_bloginfo('url');
|
||||
$check_image_url = explode('//', $image);
|
||||
$check_image_url = explode('/', $check_image_url[1]);
|
||||
$check_dir_url = explode('//', $url);
|
||||
$check_dir_url = explode('/', $check_dir_url[1]);
|
||||
// Check in both ways
|
||||
if (@strpos($check_image_url[0], $check_dir_url[0]) !== false
|
||||
|| @strpos($check_dir_url[0], $check_image_url[0]) !== false) {
|
||||
$is_outsider = 0;
|
||||
}
|
||||
|
||||
// Check if it's in upload path
|
||||
$upload_dir = wp_upload_dir();
|
||||
unset($check_image_url[0]);
|
||||
if (empty($upload_dir['error'])) {
|
||||
$check_upload_dir = explode('//', trim($upload_dir['baseurl']));
|
||||
$check_upload_dir = explode('/', $check_upload_dir[1]);
|
||||
unset($check_upload_dir[0]);
|
||||
if (strpos(implode('/', $check_image_url),
|
||||
implode('/', $check_upload_dir)) !== false) {
|
||||
$is_in_upload_path = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$is_outsider) {
|
||||
// Check if it's attachment
|
||||
global $wpdb;
|
||||
$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts}
|
||||
WHERE post_type = 'attachment' AND guid=%s",
|
||||
$image));
|
||||
// Calculate abspath
|
||||
// Uploaded
|
||||
if ($is_in_upload_path) {
|
||||
$info = pathinfo($image);
|
||||
$path = parse_url($image);
|
||||
if (!is_multisite()) {
|
||||
$temp = parse_url(network_home_url());
|
||||
} else {
|
||||
$temp = parse_url(get_bloginfo('url'));
|
||||
}
|
||||
$port = isset($path['port']) ? ':' . $path['port'] : '';
|
||||
$info['dirname'] = $temp['scheme'] . '://' . $temp['host'] . $port . dirname($path['path']);
|
||||
$abspath = str_replace(
|
||||
$upload_dir['baseurl'], $upload_dir['basedir'],
|
||||
$info['dirname']
|
||||
);
|
||||
} else {// Manually uploaded
|
||||
unset($check_image_url[1]);
|
||||
if (!is_multisite()) {
|
||||
$abspath = dirname(ABSPATH . implode(DIRECTORY_SEPARATOR,
|
||||
$check_image_url));
|
||||
} else {
|
||||
$network_url = network_home_url();
|
||||
$network_url = explode('//', $network_url);
|
||||
$network_url = explode('/', $network_url[1]);
|
||||
unset($network_url[0], $network_url[1], $check_image_url[1]);
|
||||
$abspath = dirname(ABSPATH . implode(DIRECTORY_SEPARATOR,
|
||||
$network_url + $check_image_url));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'image' => basename($image),
|
||||
'image_name' => basename($image, '.' . $extension),
|
||||
'extension' => $extension,
|
||||
'abspath' => realpath($abspath),
|
||||
'relpath' => dirname($image),
|
||||
'fullabspath' => realpath($abspath . DIRECTORY_SEPARATOR . basename($image)),
|
||||
'fullrelpath' => $image,
|
||||
'is_outsider' => $is_outsider,
|
||||
'is_in_upload_path' => $is_in_upload_path,
|
||||
'is_attachment' => !empty($attachment_id) ? $attachment_id : 0,
|
||||
'error' => $error,
|
||||
);
|
||||
|
||||
// Cache it
|
||||
$cache[md5($image)] = $data;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strips GET vars from value.
|
||||
*
|
||||
* @param type $value
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_image_value_filter($value) {
|
||||
return strtok($value, '?');
|
||||
}
|
||||
@ -1,92 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Register data (called automatically).
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_numeric() {
|
||||
return array(
|
||||
'id' => 'wpcf-numeric',
|
||||
'title' => __('Numeric', 'wpcf'),
|
||||
'description' => __('Numeric', 'wpcf'),
|
||||
'validate' => array('required', 'number' => array('forced' => true)),
|
||||
'inherited_field_type' => 'textfield',
|
||||
'meta_key_type' => 'NUMERIC',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor callback form.
|
||||
*/
|
||||
function wpcf_fields_numeric_editor_callback() {
|
||||
wp_enqueue_style('wpcf-fields', WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css',
|
||||
array(), WPCF_VERSION);
|
||||
wp_enqueue_script('jquery');
|
||||
|
||||
// Get field
|
||||
$field = wpcf_admin_fields_get_field($_GET['field_id']);
|
||||
if (empty($field)) {
|
||||
_e('Wrong field specified', 'wpcf');
|
||||
die();
|
||||
}
|
||||
|
||||
$last_settings = wpcf_admin_fields_get_field_last_settings($_GET['field_id']);
|
||||
|
||||
$form = array();
|
||||
$form['#form']['callback'] = 'wpcf_fields_numeric_editor_submit';
|
||||
$form['format'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => __('Output format', 'wpcf'),
|
||||
'#description' => __("Similar to sprintf function. Default: 'FIELD_NAME: FIELD_VALUE'.", 'wpcf'),
|
||||
'#name' => 'format',
|
||||
'#value' => isset($last_settings['format']) ? $last_settings['format'] : 'FIELD_NAME: FIELD_VALUE',
|
||||
);
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'submit',
|
||||
'#value' => __('Insert shortcode', 'wpcf'),
|
||||
'#attributes' => array('class' => 'button-primary'),
|
||||
);
|
||||
$f = wpcf_form('wpcf-form', $form);
|
||||
wpcf_admin_ajax_head('Insert numeric', 'wpcf');
|
||||
echo '<form method="post" action="">';
|
||||
echo $f->renderForm();
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor callback form submit.
|
||||
*/
|
||||
function wpcf_fields_numeric_editor_submit() {
|
||||
$add = '';
|
||||
if (!empty($_POST['format'])) {
|
||||
$add .= ' format="' . strval($_POST['format']) . '"';
|
||||
}
|
||||
$field = wpcf_admin_fields_get_field($_GET['field_id']);
|
||||
if (!empty($field)) {
|
||||
$shortcode = wpcf_fields_get_shortcode($field, $add);
|
||||
wpcf_admin_fields_save_field_last_settings($_GET['field_id'],
|
||||
array('format' => $_POST['format'])
|
||||
);
|
||||
echo wpcf_admin_fields_popup_insert_shortcode_js($shortcode);
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* View function.
|
||||
*
|
||||
* @param type $params
|
||||
*/
|
||||
function wpcf_fields_numeric_view($params) {
|
||||
$output = '';
|
||||
if (!empty($params['format'])) {
|
||||
$patterns = array('/FIELD_NAME/', '/FIELD_VALUE/');
|
||||
$replacements = array($params['field']['name'], $params['field_value']);
|
||||
$output = preg_replace($patterns, $replacements, $params['format']);
|
||||
$output = sprintf($output, $params['field_value']);
|
||||
} else {
|
||||
$output = $params['field_value'];
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Register data (called automatically).
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_phone() {
|
||||
return array(
|
||||
'id' => 'wpcf-phone',
|
||||
'title' => __('Phone', 'wpcf'),
|
||||
'description' => __('Phone', 'wpcf'),
|
||||
'validate' => array('required'),
|
||||
'inherited_field_type' => 'textfield',
|
||||
);
|
||||
}
|
||||
@ -1,197 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Register data (called automatically).
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_radio() {
|
||||
return array(
|
||||
'id' => 'wpcf-radio',
|
||||
'title' => __('Radio', 'wpcf'),
|
||||
'description' => __('Radio', 'wpcf'),
|
||||
'validate' => array('required'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Form data for post edit page.
|
||||
*
|
||||
* @param type $field
|
||||
*/
|
||||
function wpcf_fields_radio_meta_box_form($field) {
|
||||
$options = array();
|
||||
$default_value = '';
|
||||
|
||||
if (!empty($field['data']['options'])) {
|
||||
foreach ($field['data']['options'] as $option_key => $option) {
|
||||
// Skip default value record
|
||||
if ($option_key == 'default') {
|
||||
continue;
|
||||
}
|
||||
// Set default value
|
||||
if (!empty($field['data']['options']['default'])
|
||||
&& $option_key == $field['data']['options']['default']) {
|
||||
$default_value = $option['value'];
|
||||
}
|
||||
$options[$option['title']] = array(
|
||||
'#value' => $option['value'],
|
||||
'#title' => wpcf_translate('field ' . $field['id'] . ' option '
|
||||
. $option_key . ' title', $option['title']),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($field['value'])
|
||||
|| ($field['value'] === 0 || $field['value'] === '0')) {
|
||||
$default_value = $field['value'];
|
||||
}
|
||||
|
||||
return array(
|
||||
'#type' => 'radios',
|
||||
'#default_value' => $default_value,
|
||||
'#options' => $options,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor callback form.
|
||||
*/
|
||||
function wpcf_fields_radio_editor_callback() {
|
||||
wpcf_admin_ajax_head('Insert checkbox', 'wpcf');
|
||||
$field = wpcf_admin_fields_get_field($_GET['field_id']);
|
||||
if (empty($field)) {
|
||||
echo '<div class="message error"><p>' . __('Wrong field specified',
|
||||
'wpcf') . '</p></div>';
|
||||
wpcf_admin_ajax_footer();
|
||||
return '';
|
||||
}
|
||||
$form = array();
|
||||
$form['#form']['callback'] = 'wpcf_fields_radio_editor_submit';
|
||||
$form['display'] = array(
|
||||
'#type' => 'radios',
|
||||
'#default_value' => 'db',
|
||||
'#name' => 'display',
|
||||
'#options' => array(
|
||||
'display_from_db' => array(
|
||||
'#title' => __('Display the value of this field from the database',
|
||||
'wpcf'),
|
||||
'#name' => 'display',
|
||||
'#value' => 'db',
|
||||
'#inline' => true,
|
||||
'#after' => '<br />'
|
||||
),
|
||||
'display_values' => array(
|
||||
'#title' => __('Show one of these values:', 'wpcf'),
|
||||
'#name' => 'display',
|
||||
'#value' => 'value',
|
||||
),
|
||||
),
|
||||
'#inline' => true,
|
||||
);
|
||||
if (!empty($field['data']['options'])) {
|
||||
$form['table-open'] = array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => '<table style="margin-top:20px;" cellpadding="0" cellspacing="8">',
|
||||
);
|
||||
foreach ($field['data']['options'] as $option_id => $option) {
|
||||
if ($option_id == 'default') {
|
||||
continue;
|
||||
}
|
||||
$value = isset($option['display_value']) ? $option['display_value'] : $option['value'];
|
||||
$form['display-value-' . $option_id] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => $option['title'],
|
||||
'#name' => 'options[' . $option_id . ']',
|
||||
'#value' => $value,
|
||||
'#inline' => true,
|
||||
'#pattern' => '<tr><td style="text-align:right;"><LABEL></td><td><ELEMENT></td></tr>',
|
||||
'#attributes' => array('style' => 'width:200px;'),
|
||||
);
|
||||
}
|
||||
$form['table-close'] = array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => '</table>',
|
||||
);
|
||||
}
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'submit',
|
||||
'#value' => __('Save Changes'),
|
||||
'#attributes' => array('class' => 'button-primary'),
|
||||
);
|
||||
$f = wpcf_form('wpcf-form', $form);
|
||||
|
||||
echo '<form method="post" action="">';
|
||||
echo $f->renderForm();
|
||||
echo '</form>';
|
||||
wpcf_admin_ajax_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor callback form submit.
|
||||
*/
|
||||
function wpcf_fields_radio_editor_submit() {
|
||||
$add = '';
|
||||
$field = wpcf_admin_fields_get_field($_GET['field_id']);
|
||||
if (!empty($field)) {
|
||||
if ($_POST['display'] == 'value' && !empty($_POST['options'])) {
|
||||
$shortcode = '';
|
||||
foreach ($_POST['options'] as $option_id => $value) {
|
||||
$shortcode .= '[types field="' . $field['slug']
|
||||
. '" option="' . $option_id . '"]' . $value
|
||||
. '[/types] ';
|
||||
}
|
||||
} else {
|
||||
$shortcode = wpcf_fields_get_shortcode($field, $add);
|
||||
}
|
||||
echo wpcf_admin_fields_popup_insert_shortcode_js($shortcode);
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* View function.
|
||||
*
|
||||
* @param type $params
|
||||
*/
|
||||
function wpcf_fields_radio_view($params) {
|
||||
if ($params['style'] == 'raw') {
|
||||
return '';
|
||||
}
|
||||
$field = wpcf_fields_get_field_by_slug($params['field']['slug']);
|
||||
$output = '';
|
||||
|
||||
// See if user specified output for each field
|
||||
if (isset($params['option'])) {
|
||||
foreach ($field['data']['options'] as $option_key => $option) {
|
||||
if (isset($option['value'])
|
||||
&& $option['value'] == $params['field_value']
|
||||
&& $option_key == $params['option']) {
|
||||
return htmlspecialchars_decode($params['#content']);
|
||||
}
|
||||
}
|
||||
// return ' ';
|
||||
return '__wpcf_skip_empty';
|
||||
}
|
||||
|
||||
if (!empty($field['data']['options'])) {
|
||||
$field_value = $params['field_value'];
|
||||
foreach ($field['data']['options'] as $option_key => $option) {
|
||||
if (isset($option['value'])
|
||||
&& $option['value'] == $params['field_value']) {
|
||||
$field_value = wpcf_translate('field ' . $params['field']['id'] . ' option '
|
||||
. $option_key . ' title', $option['title']);
|
||||
if (isset($params['field']['data']['display'])
|
||||
&& $params['field']['data']['display'] != 'db'
|
||||
&& !empty($option['display_value'])) {
|
||||
$field_value = wpcf_translate('field ' . $params['field']['id'] . ' option '
|
||||
. $option_key . ' display value',
|
||||
$option['display_value']);
|
||||
}
|
||||
}
|
||||
}
|
||||
$output = $field_value;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
@ -1,78 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Register data (called automatically).
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_select() {
|
||||
return array(
|
||||
'id' => 'wpcf-select',
|
||||
'title' => __('Select', 'wpcf'),
|
||||
'description' => __('Select', 'wpcf'),
|
||||
'validate' => array('required'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Form data for post edit page.
|
||||
*
|
||||
* @param type $field
|
||||
*/
|
||||
function wpcf_fields_select_meta_box_form($field) {
|
||||
$options = array();
|
||||
$default_value = null;
|
||||
|
||||
if (!empty($field['data']['options'])) {
|
||||
foreach ($field['data']['options'] as $option_key => $option) {
|
||||
// Skip default value record
|
||||
if ($option_key == 'default') {
|
||||
continue;
|
||||
}
|
||||
// Set default value
|
||||
if (!empty($field['data']['options']['default'])
|
||||
&& $option_key == $field['data']['options']['default']) {
|
||||
$default_value = $option['value'];
|
||||
}
|
||||
$options[$option['title']] = array(
|
||||
'#value' => $option['value'],
|
||||
'#title' => wpcf_translate('field ' . $field['id'] . ' option '
|
||||
. $option_key . ' title', $option['title']),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($field['value'])
|
||||
|| ($field['value'] === 0 || $field['value'] === '0')) {
|
||||
$default_value = $field['value'];
|
||||
}
|
||||
|
||||
$element = array(
|
||||
'#type' => 'select',
|
||||
'#default_value' => $default_value,
|
||||
'#options' => $options,
|
||||
);
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* View function.
|
||||
*
|
||||
* @param type $params
|
||||
*/
|
||||
function wpcf_fields_select_view($params) {
|
||||
$field = wpcf_fields_get_field_by_slug($params['field']['slug']);
|
||||
$output = '';
|
||||
if (!empty($field['data']['options'])) {
|
||||
$field_value = $params['field_value'];
|
||||
foreach ($field['data']['options'] as $option_key => $option) {
|
||||
if (isset($option['value'])
|
||||
&& $option['value'] == $params['field_value']) {
|
||||
$field_value = wpcf_translate('field ' . $params['field']['id'] . ' option '
|
||||
. $option_key . ' title', $option['title']);
|
||||
}
|
||||
}
|
||||
$output = $field_value;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
@ -1,415 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Register data (called automatically).
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_skype() {
|
||||
return array(
|
||||
'id' => 'wpcf-skype',
|
||||
'title' => __('Skype', 'wpcf'),
|
||||
'description' => __('Skype', 'wpcf'),
|
||||
'validate' => array('required'),
|
||||
);
|
||||
}
|
||||
|
||||
add_filter('wpcf_pr_fields_type_skype_value_save',
|
||||
'wpcf_pr_fields_type_skype_value_save_filter', 10, 3);
|
||||
|
||||
/**
|
||||
* Form data for post edit page.
|
||||
*
|
||||
* @param type $field
|
||||
*/
|
||||
function wpcf_fields_skype_meta_box_form($field) {
|
||||
if (isset($field['value'])) {
|
||||
$field['value'] = maybe_unserialize($field['value']);
|
||||
}
|
||||
$form = array();
|
||||
add_filter('wpcf_fields_shortcode_slug_' . $field['slug'],
|
||||
'wpcf_fields_skype_shortcode_filter', 10, 2);
|
||||
$rand = mt_rand();
|
||||
$form['skypename'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#value' => isset($field['value']['skypename']) ? $field['value']['skypename'] : '',
|
||||
'#name' => 'wpcf[' . $field['slug'] . '][skypename]',
|
||||
'#id' => 'wpcf-fields-skype-' . $field['slug'] . '-' . $rand . '-skypename',
|
||||
'#inline' => true,
|
||||
'#suffix' => ' ' . __('Skype name', 'wpcf'),
|
||||
'#description' => '',
|
||||
'#prefix' => !empty($field['description']) ? wpcf_translate('field ' . $field['id'] . ' description',
|
||||
$field['description'])
|
||||
. '<br /><br />' : '',
|
||||
'#attributes' => array('style' => 'width:60%;'),
|
||||
'#_validate_this' => true,
|
||||
'#before' => '<div class="wpcf-skype">',
|
||||
);
|
||||
|
||||
$form['style'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => isset($field['value']['style']) ? $field['value']['style'] : 'btn2',
|
||||
'#name' => 'wpcf[' . $field['slug'] . '][style]',
|
||||
'#id' => 'wpcf-fields-skype-' . $field['slug'] . '-' . $rand . '-style',
|
||||
);
|
||||
|
||||
$preview_skypename = !empty($field['value']['skypename']) ? $field['value']['skypename'] : '--not--';
|
||||
$preview_style = !empty($field['value']['style']) ? $field['value']['style'] : 'btn2';
|
||||
$preview = wpcf_fields_skype_get_button_image($preview_skypename,
|
||||
$preview_style);
|
||||
|
||||
// Set button
|
||||
if (isset($field['disable'])) {
|
||||
$edit_button = '';
|
||||
} else {
|
||||
$edit_button = '<br />'
|
||||
. '<a href="'
|
||||
. admin_url('admin-ajax.php?action=wpcf_ajax&'
|
||||
. 'wpcf_action=insert_skype_button&_wpnonce='
|
||||
. wp_create_nonce('insert_skype_button')
|
||||
. '&update=wpcf-fields-skype-'
|
||||
. $field['slug'] . '-' . $rand . '&skypename=' . $preview_skypename
|
||||
. '&style=' . $preview_style
|
||||
. '&keepThis=true&TB_iframe=true&width=500&height=500')
|
||||
. '"'
|
||||
. ' class="thickbox wpcf-fields-skype button-secondary"'
|
||||
. ' title="' . __('Edit Skype button', 'wpcf') . '"'
|
||||
. '>'
|
||||
. __('Edit Skype button', 'wpcf') . '</a>';
|
||||
}
|
||||
|
||||
$form['markup'] = array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => '<br /><div class="wpcf-form-item">'
|
||||
. '<div id="wpcf-fields-skype-'
|
||||
. $field['slug'] . '-' . $rand . '-preview">' . $preview . '</div>'
|
||||
. $edit_button . '</div>',
|
||||
);
|
||||
$form['markup-close'] = array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => '</div>',
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcode filter.
|
||||
*
|
||||
* @param type $shortcode
|
||||
* @param type $field
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_skype_shortcode_filter($shortcode, $field) {
|
||||
return $shortcode;
|
||||
$add = '';
|
||||
$add .= isset($field['value']['skypename']) ? ' skypename="' . $field['value']['skypename'] . '"' : '';
|
||||
// $add .= isset($field['value']['style']) ? ' style="' . $field['value']['style'] . '"' : '';
|
||||
return str_replace(']', $add . ']', $shortcode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit Skype button submit.
|
||||
*/
|
||||
function wpcf_fields_skype_meta_box_submit() {
|
||||
$update = esc_attr($_GET['update']);
|
||||
$preview = wpcf_fields_skype_get_button_image(esc_attr($_POST['skypename']),
|
||||
esc_attr($_POST['buttonstyle']));
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
jQuery(document).ready(function(){
|
||||
window.parent.jQuery('#<?php echo $update; ?>-skypename').val('<?php echo esc_js($_POST['skypename']); ?>');
|
||||
window.parent.jQuery('#<?php echo $update; ?>-style').val('<?php echo esc_js($_POST['buttonstyle']); ?>');
|
||||
window.parent.jQuery('#<?php echo $update; ?>-preview').html('<?php echo $preview; ?>');
|
||||
window.parent.jQuery('#TB_closeWindowButton').trigger('click');
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit Skype button AJAX call.
|
||||
*/
|
||||
function wpcf_fields_skype_meta_box_ajax() {
|
||||
if (isset($_POST['_wpnonce_wpcf_form']) && wp_verify_nonce($_POST['_wpnonce_wpcf_form'],
|
||||
'wpcf-form')) {
|
||||
add_action('admin_head_wpcf_ajax', 'wpcf_fields_skype_meta_box_submit');
|
||||
}
|
||||
wp_enqueue_script('jquery');
|
||||
wpcf_admin_ajax_head(__('Insert skype button', 'wpcf'));
|
||||
|
||||
?>
|
||||
<form method="post" action="">
|
||||
<div id="paddedContent">
|
||||
<div id="step1">
|
||||
<h2><?php
|
||||
_e('Enter your Skype Name', 'wpcf');
|
||||
|
||||
?></h2>
|
||||
<p>
|
||||
<input id="btn-skypename" name="skypename" value="<?php echo $_GET['skypename']; ?>" type="text" />
|
||||
</p>
|
||||
</div>
|
||||
<div id="step2">
|
||||
<h2><?php
|
||||
_e('Select a button from below', 'wpcf');
|
||||
|
||||
?></h2>
|
||||
<div id="static-buttons">
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="445">
|
||||
|
||||
<colgroup><col span="1" width="223">
|
||||
<col span="1" width="222">
|
||||
</colgroup><tbody><tr>
|
||||
<td colspan="1" rowspan="1">
|
||||
<label for="btn1">
|
||||
<input <?php
|
||||
if ($_GET['style'] == 'btn1')
|
||||
echo 'checked="checked" ';
|
||||
|
||||
?>id="btn1" name="buttonstyle" tabindex="2" value="btn1" type="radio" />
|
||||
<img alt="" id="btn1-img" src="http://www.skypeassets.com/i/legacy/images/share/buttons/call_green_white_153x63.png" height="63" width="153" />
|
||||
</label>
|
||||
</td>
|
||||
<td colspan="1" rowspan="1">
|
||||
<label for="btn2">
|
||||
<input <?php
|
||||
if ($_GET['style'] == 'btn2')
|
||||
echo 'checked="checked" ';
|
||||
|
||||
?>id="btn2" name="buttonstyle" tabindex="3" value="btn2" type="radio" />
|
||||
<img alt="" id="btn2-img" src="http://www.skypeassets.com/i/legacy/images/share/buttons/call_blue_white_124x52.png" height="52" width="125" />
|
||||
</label>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="1" rowspan="1">
|
||||
<label for="btn3">
|
||||
<input <?php
|
||||
if ($_GET['style'] == 'btn3')
|
||||
echo 'checked="checked" ';
|
||||
|
||||
?>id="btn3" name="buttonstyle" tabindex="4" value="btn3" type="radio" />
|
||||
<img alt="" id="btn3-img" src="http://www.skypeassets.com/i/legacy/images/share/buttons/call_green_white_92x82.png" height="82" width="92" />
|
||||
</label>
|
||||
</td>
|
||||
<td colspan="1" rowspan="1">
|
||||
<label for="btn4">
|
||||
<input <?php
|
||||
if ($_GET['style'] == 'btn4')
|
||||
echo 'checked="checked" ';
|
||||
|
||||
?>id="btn4" name="buttonstyle" tabindex="5" value="btn4" type="radio" />
|
||||
<img alt="" id="btn4-img" src="http://www.skypeassets.com/i/legacy/images/share/buttons/call_blue_transparent_34x34.png" height="34" width="34" />
|
||||
</label>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</tbody></table>
|
||||
</div>
|
||||
<h2><?php
|
||||
_e('Skype buttons with status', 'wpcf');
|
||||
|
||||
?></h2>
|
||||
<p><?php
|
||||
_e('If you choose to show your Skype status, your Skype button will always reflect your availability on Skype. This status will be shown to everyone, whether they’re in your contact list or not.',
|
||||
'wpcf');
|
||||
|
||||
?></p>
|
||||
<div id="status-buttons">
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="445">
|
||||
<colgroup><col span="1" width="223">
|
||||
<col span="1" width="222">
|
||||
</colgroup><tbody><tr>
|
||||
|
||||
<td colspan="1" rowspan="1">
|
||||
<label for="btn5">
|
||||
<input <?php
|
||||
if ($_GET['style'] == 'btn5')
|
||||
echo 'checked="checked" ';
|
||||
|
||||
?>id="btn5" name="buttonstyle" tabindex="6" value="btn5" type="radio" />
|
||||
<img alt="" id="btn5-img" src="http://www.skypeassets.com/i/legacy/images/share/buttons/anim_balloon.gif" height="60" width="150" />
|
||||
</label>
|
||||
</td>
|
||||
<td colspan="1" rowspan="1">
|
||||
<label for="btn6">
|
||||
<input <?php
|
||||
if ($_GET['style'] == 'btn6')
|
||||
echo 'checked="checked" ';
|
||||
|
||||
?>id="btn6" name="buttonstyle" tabindex="7" value="btn6" type="radio" />
|
||||
<img alt="" id="btn6-img" src="http://www.skypeassets.com/i/legacy/images/share/buttons/anim_rectangle.gif" height="44" width="182" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
wp_nonce_field('wpcf-form', '_wpnonce_wpcf_form');
|
||||
|
||||
?>
|
||||
<br /><br /><input type="submit" class="button-primary" value="<?php
|
||||
_e('Insert skype button', 'wpcf');
|
||||
|
||||
?>" />
|
||||
</form>
|
||||
<?php
|
||||
$update = esc_attr($_GET['update']);
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
jQuery(document).ready(function(){
|
||||
jQuery('#btn-skypename').val(window.parent.jQuery('#<?php echo $update; ?>-skypename').val());
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
wpcf_admin_ajax_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML formatted skype button.
|
||||
*
|
||||
* @param type $skypename
|
||||
* @param type $template
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_skype_get_button($skypename, $template = '') {
|
||||
|
||||
if (empty($skypename)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
switch ($template) {
|
||||
|
||||
case 'btn1':
|
||||
// Call me big drawn
|
||||
$output = '<script type="text/javascript" src="http://download.skype.com/share/skypebuttons/js/skypeCheck.js"></script>
|
||||
<a href="skype:' . $skypename . '?call"><img src="http://download.skype.com/share/skypebuttons/buttons/call_green_white_153x63.png" style="border: none;" width="153" height="63" alt="Skype Me™!" /></a>';
|
||||
break;
|
||||
|
||||
case 'btn4':
|
||||
// Call me small
|
||||
$output = '<script type="text/javascript" src="http://download.skype.com/share/skypebuttons/js/skypeCheck.js"></script>
|
||||
<a href="skype:' . $skypename . '?call"><img src="http://download.skype.com/share/skypebuttons/buttons/call_blue_transparent_34x34.png" style="border: none;" width="34" height="34" alt="Skype Me™!" /></a>';
|
||||
break;
|
||||
|
||||
case 'btn3':
|
||||
// Call me small drawn
|
||||
$output = '<script type="text/javascript" src="http://download.skype.com/share/skypebuttons/js/skypeCheck.js"></script>
|
||||
<a href="skype:' . $skypename . '?call"><img src="http://download.skype.com/share/skypebuttons/buttons/call_green_white_92x82.png" style="border: none;" width="92" height="82" alt="Skype Me™!" /></a>';
|
||||
break;
|
||||
|
||||
case 'btn6':
|
||||
// Status
|
||||
$output = '<script type="text/javascript" src="http://download.skype.com/share/skypebuttons/js/skypeCheck.js"></script>
|
||||
<a href="skype:' . $skypename . '?call"><img src="http://mystatus.skype.com/bigclassic/' . $skypename . '" style="border: none;" width="182" height="44" alt="My status" /></a>';
|
||||
break;
|
||||
|
||||
case 'btn5':
|
||||
// Status drawn
|
||||
$output = '<script type="text/javascript" src="http://download.skype.com/share/skypebuttons/js/skypeCheck.js"></script>
|
||||
<a href="skype:' . $skypename . '?call"><img src="http://mystatus.skype.com/balloon/' . $skypename . '" style="border: none;" width="150" height="60" alt="My status" /></a>';
|
||||
break;
|
||||
|
||||
default:
|
||||
// Call me big
|
||||
$output = '<script type="text/javascript" src="http://download.skype.com/share/skypebuttons/js/skypeCheck.js"></script>
|
||||
<a href="skype:' . $skypename . '?call"><img src="http://download.skype.com/share/skypebuttons/buttons/call_blue_white_124x52.png" style="border: none;" width="124" height="52" alt="Skype Me™!" /></a>';
|
||||
break;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML formatted skype button image.
|
||||
*
|
||||
* @param type $skypename
|
||||
* @param type $template
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_skype_get_button_image($skypename, $template = '') {
|
||||
|
||||
if (empty($skypename)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
switch ($template) {
|
||||
|
||||
case 'btn1':
|
||||
// Call me big drawn
|
||||
$output = '<img src="http://download.skype.com/share/skypebuttons/buttons/call_green_white_153x63.png" style="border: none;" width="153" height="63" alt="Skype Me™!" />';
|
||||
break;
|
||||
|
||||
case 'btn4':
|
||||
// Call me small
|
||||
$output = '<img src="http://download.skype.com/share/skypebuttons/buttons/call_blue_transparent_34x34.png" style="border: none;" width="34" height="34" alt="Skype Me™!" />';
|
||||
break;
|
||||
|
||||
case 'btn3':
|
||||
// Call me small drawn
|
||||
$output = '<img src="http://download.skype.com/share/skypebuttons/buttons/call_green_white_92x82.png" style="border: none;" width="92" height="82" alt="Skype Me™!" />';
|
||||
break;
|
||||
|
||||
case 'btn6':
|
||||
// Status
|
||||
$output = '<img src="http://mystatus.skype.com/bigclassic/' . $skypename . '" style="border: none;" width="182" height="44" alt="My status" />';
|
||||
break;
|
||||
|
||||
case 'btn5':
|
||||
// Status drawn
|
||||
$output = '<img src="http://mystatus.skype.com/balloon/' . $skypename . '" style="border: none;" width="150" height="60" alt="My status" />';
|
||||
break;
|
||||
|
||||
default:
|
||||
// Call me big
|
||||
$output = '<img src="http://download.skype.com/share/skypebuttons/buttons/call_blue_white_124x52.png" style="border: none;" width="124" height="52" alt="Skype Me™!" />';
|
||||
break;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* View function.
|
||||
*
|
||||
* @param type $params
|
||||
*/
|
||||
function wpcf_fields_skype_view($params) {
|
||||
if (!isset($params['field_value']['skypename'])) {
|
||||
return '__wpcf_skip_empty';
|
||||
}
|
||||
if ($params['style'] == 'raw') {
|
||||
return $params['field_value']['skypename'];
|
||||
}
|
||||
// Style can be overrided by params (shortcode)
|
||||
if (!isset($params['field_value']['style'])) {
|
||||
$params['field_value']['style'] = '';
|
||||
}
|
||||
$style = (!empty($params['style']) && $params['style'] != 'default') ? $params['style'] : $params['field_value']['style'];
|
||||
$content = wpcf_fields_skype_get_button($params['field_value']['skypename'],
|
||||
$style);
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters post relationship save data.
|
||||
*
|
||||
* @param type $data
|
||||
* @param type $meta_key
|
||||
* @param type $post_id
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_pr_fields_type_skype_value_save_filter($data, $meta_key = null,
|
||||
$post_id = null) {
|
||||
$meta = (array) get_post_meta($post_id, $meta_key, true);
|
||||
$meta['skypename'] = $data;
|
||||
$data = $meta;
|
||||
return $data;
|
||||
}
|
||||
@ -1,43 +0,0 @@
|
||||
<?php
|
||||
add_filter('wpcf_fields_type_textarea_value_display',
|
||||
'wpcf_fields_textarea_value_display_filter');
|
||||
|
||||
/**
|
||||
* Register data (called automatically).
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_textarea() {
|
||||
return array(
|
||||
'id' => 'wpcf-textarea',
|
||||
'title' => __('Multiple lines', 'wpcf'),
|
||||
'description' => __('Textarea', 'wpcf'),
|
||||
'validate' => array('required'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats display data.
|
||||
*/
|
||||
|
||||
function wpcf_fields_textarea_value_display_filter($value) {
|
||||
|
||||
// see if it's already wrapped in <p> ... </p>
|
||||
$wrapped_in_p = false;
|
||||
if (!empty($value) && strpos($value, '<p>') === 0 && strrpos($value, "</p>\n") == strlen($value) - 5 ) {
|
||||
$wrapped_in_p = true;
|
||||
}
|
||||
|
||||
// use wpautop for converting line feeds to <br />, etc
|
||||
$value = wpautop($value);
|
||||
|
||||
if (!$wrapped_in_p) {
|
||||
// If it wasn't wrapped then remove the wrapping wpautop has added.
|
||||
if(!empty($value) && strpos($value, '<p>') === 0 && strrpos($value, "</p>\n") == strlen($value) - 5 ) {
|
||||
// unwrapp the <p> ..... </p>
|
||||
$value = substr($value, 3, -5);
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Register data (called automatically).
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_textfield() {
|
||||
return array(
|
||||
'id' => 'wpcf-texfield',
|
||||
'title' => __('Single line', 'wpcf'),
|
||||
'description' => __('Texfield', 'wpcf'),
|
||||
'validate' => array('required'),
|
||||
);
|
||||
}
|
||||
@ -1,105 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Register data (called automatically).
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_url() {
|
||||
return array(
|
||||
'id' => 'wpcf-url',
|
||||
'title' => 'URL',
|
||||
'description' => 'URL',
|
||||
'validate' => array('required', 'url'),
|
||||
'inherited_field_type' => 'textfield',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* View function.
|
||||
*
|
||||
* @param type $params
|
||||
*/
|
||||
function wpcf_fields_url_view($params) {
|
||||
$title = '';
|
||||
$add = '';
|
||||
if (!empty($params['title'])) {
|
||||
$add .= ' title="' . $params['title'] . '"';
|
||||
$title .= $params['title'];
|
||||
} else {
|
||||
$add .= ' title="' . $params['field_value'] . '"';
|
||||
$title .= $params['field_value'];
|
||||
}
|
||||
if (!empty($params['class'])) {
|
||||
$add .= ' class="' . $params['class'] . '"';
|
||||
}
|
||||
if (!empty($params['style'])) {
|
||||
$add .= ' style="' . $params['style'] . '"';
|
||||
}
|
||||
$output = '<a href="' . $params['field_value'] . '"' . $add . '>'
|
||||
. $title . '</a>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor callback form.
|
||||
*/
|
||||
function wpcf_fields_url_editor_callback() {
|
||||
$last_settings = wpcf_admin_fields_get_field_last_settings($_GET['field_id']);
|
||||
$form = array();
|
||||
$form['#form']['callback'] = 'wpcf_fields_url_editor_submit';
|
||||
$form['title'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => __('Title', 'wpcf'),
|
||||
'#description' => __('If set, this text will be displayed instead of raw data'),
|
||||
'#name' => 'title',
|
||||
'#value' => isset($last_settings['title']) ? $last_settings['title'] : '',
|
||||
);
|
||||
$form['class'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => __('Class', 'wpcf'),
|
||||
'#name' => 'class',
|
||||
'#value' => isset($last_settings['class']) ? $last_settings['class'] : '',
|
||||
);
|
||||
$form['style'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => __('Style', 'wpcf'),
|
||||
'#name' => 'style',
|
||||
'#value' => isset($last_settings['style']) ? $last_settings['style'] : '',
|
||||
);
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'submit',
|
||||
'#value' => __('Save Changes'),
|
||||
'#attributes' => array('class' => 'button-primary'),
|
||||
);
|
||||
$f = wpcf_form('wpcf-form', $form);
|
||||
wpcf_admin_ajax_head('Insert URL', 'wpcf');
|
||||
echo '<form method="post" action="">';
|
||||
echo $f->renderForm();
|
||||
echo '</form>';
|
||||
wpcf_admin_ajax_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor callback form submit.
|
||||
*/
|
||||
function wpcf_fields_url_editor_submit() {
|
||||
$add = '';
|
||||
if (!empty($_POST['title'])) {
|
||||
$add .= ' title="' . strval($_POST['title']) . '"';
|
||||
}
|
||||
if (!empty($_POST['class'])) {
|
||||
$add .= ' class="' . $_POST['class'] . '"';
|
||||
}
|
||||
if (!empty($_POST['style'])) {
|
||||
$add .= ' style="' . $_POST['style'] . '"';
|
||||
}
|
||||
$field = wpcf_admin_fields_get_field($_GET['field_id']);
|
||||
if (!empty($field)) {
|
||||
$shortcode = wpcf_fields_get_shortcode($field, $add);
|
||||
wpcf_admin_fields_save_field_last_settings($_GET['field_id'], $_POST);
|
||||
echo wpcf_admin_fields_popup_insert_shortcode_js($shortcode);
|
||||
die();
|
||||
}
|
||||
}
|
||||
@ -1,137 +0,0 @@
|
||||
<?php
|
||||
if (wpcf_compare_wp_version('3.3', '<')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register data (called automatically).
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_wysiwyg() {
|
||||
$settings = array(
|
||||
'id' => 'wpcf-wysiwyg',
|
||||
'title' => __('WYSIWYG', 'wpcf'),
|
||||
'description' => __('WYSIWYG editor', 'wpcf'),
|
||||
'meta_box_css' => array(
|
||||
'wpcf-fields-wysiwyg' => array(
|
||||
'inline' => 'wpcf_fields_wysiwyg_css',
|
||||
),
|
||||
),
|
||||
);
|
||||
$settings['wp_version'] = '3.3';
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta box form.
|
||||
*
|
||||
* @param type $field
|
||||
* @return array
|
||||
*/
|
||||
function wpcf_fields_wysiwyg_meta_box_form($field) {
|
||||
$set = array(
|
||||
'wpautop' => true, // use wpautop?
|
||||
'media_buttons' => true, // show insert/upload button(s)
|
||||
'textarea_name' => 'wpcf[' . $field['id'] . ']', // set the textarea name to something different, square brackets [] can be used here
|
||||
'textarea_rows' => get_option('default_post_edit_rows', 10), // rows="..."
|
||||
'tabindex' => '',
|
||||
'editor_css' => '', // intended for extra styles for both visual and HTML editors buttons, needs to include the <style> tags, can use "scoped".
|
||||
'editor_class' => 'wpcf-wysiwyg', // add extra class(es) to the editor textarea
|
||||
'teeny' => false, // output the minimal editor config used in Press This
|
||||
'dfw' => false, // replace the default fullscreen with DFW (needs specific DOM elements and css)
|
||||
'tinymce' => true, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
|
||||
'quicktags' => true // load Quicktags, can be used to pass settings directly to Quicktags using an array()
|
||||
);
|
||||
$form = array(
|
||||
'#type' => 'wysiwyg',
|
||||
'#attributes' => array('class' => 'wpcf-wysiwyg'),
|
||||
'#editor_settings' => $set,
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* CSS for styling TinyMCE Editor.
|
||||
*/
|
||||
function wpcf_fields_wysiwyg_css() {
|
||||
global $wp_version;
|
||||
|
||||
?>
|
||||
<style type="text/css">
|
||||
.wpcf-wysiwyg iframe, .wpcf-wysiwyg .mceIframeContainer {
|
||||
background-color: #FFFFFF !important;
|
||||
}
|
||||
.wpcf-wysiwyg table {
|
||||
border: 1px solid #DFDFDF !important;
|
||||
}
|
||||
.wpcf-media-buttons {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.wpcf-media-buttons a {
|
||||
margin-left: 5px;
|
||||
text-decoration: none;
|
||||
}
|
||||
.wpcf-wysiwyg-switcher {
|
||||
float: right;
|
||||
margin-top: -24px;
|
||||
padding: 0;
|
||||
}
|
||||
.wpcf-wysiwyg-switcher a {
|
||||
padding: 10px;
|
||||
line-height: 25px;
|
||||
text-decoration: none;
|
||||
color: #000000;
|
||||
border: 1px solid #DFDFDF !important;
|
||||
border-bottom: none !important;
|
||||
background-color: #E8E8E8;
|
||||
margin-left: 2px;
|
||||
}
|
||||
<?php
|
||||
// WP 3.3 changes
|
||||
if (version_compare($wp_version, '3.2.1', '<=')) {
|
||||
|
||||
?>
|
||||
.wpcf-wysiwyg .mceResize {
|
||||
margin-top: -25px !important;
|
||||
}
|
||||
<?php
|
||||
}
|
||||
|
||||
?>
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* View function.
|
||||
*
|
||||
* @param type $params
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_fields_wysiwyg_view($params) {
|
||||
$output = '';
|
||||
if (!empty($params['style']) || !empty($params['class'])) {
|
||||
$output .= '<div';
|
||||
if (!empty($params['style'])) {
|
||||
$output .= ' style="' . $params['style'] . '"';
|
||||
}
|
||||
if (!empty($params['class'])) {
|
||||
$output .= ' class="' . $params['class'] . '"';
|
||||
}
|
||||
$output .= '>';
|
||||
}
|
||||
$output .= apply_filters('the_content',
|
||||
htmlspecialchars_decode(stripslashes($params['field_value'])));
|
||||
if (!empty($params['style']) || !empty($params['class'])) {
|
||||
$output .= '</div>';
|
||||
}
|
||||
return $output;
|
||||
|
||||
// $content = $params['field_value'];
|
||||
// $content = htmlspecialchars_decode(stripslashes($content));
|
||||
// $content = do_shortcode($content);
|
||||
// $content = wpautop($content);
|
||||
// return $content;
|
||||
}
|
||||
@ -1,156 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Footer credit
|
||||
*/
|
||||
if (file_exists(WPCF_EMBEDDED_INC_ABSPATH . '/src.php')) {
|
||||
include_once WPCF_EMBEDDED_INC_ABSPATH . '/src.php';
|
||||
}
|
||||
if (isset($_GET['page']) && in_array($_GET['page'],
|
||||
array('wpcf', 'wpcf-ctt', 'wpcf-import-export', 'wpcf-custom-fields-control', 'wpcf-custom-settings'))) {
|
||||
add_action('wpcf_admin_page_init', 'wpcf_footer_credit_message_init');
|
||||
}
|
||||
|
||||
/**
|
||||
* Init function.
|
||||
*/
|
||||
function wpcf_footer_credits_init() {
|
||||
$template = get_template();
|
||||
$option = get_option('wpcf_footer_credit', false);
|
||||
if ($option == false) {
|
||||
$option['active'] = wpcf_footer_credits_check_new();
|
||||
}
|
||||
if ($option['active']) {
|
||||
if (in_array($template, array('twentyten', 'twentyeleven'))) {
|
||||
add_action($template . '_credits', 'wpcf_footer_credit_render');
|
||||
} else if ($template == 'canvas') {
|
||||
add_action('woo_footer_right_before', 'wpcf_footer_credit_render');
|
||||
} else if ($template == 'genesis') {
|
||||
add_action('genesis_footer', 'wpcf_footer_credit_render', 10);
|
||||
} else if ($template == 'thesis_18') {
|
||||
add_action('thesis_hook_footer', 'wpcf_footer_credit_render', 1);
|
||||
} else if ($template == 'headway') {
|
||||
add_action('headway_footer_open', 'wpcf_footer_credit_render', 11);
|
||||
} else {
|
||||
add_action('wp_footer', 'wpcf_footer_credit_render');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if it's fresh install
|
||||
*/
|
||||
function wpcf_footer_credits_check_new() {
|
||||
$options = array(
|
||||
'wpcf-custom-taxonomies',
|
||||
'wpcf-custom-types',
|
||||
'wpcf-fields',
|
||||
);
|
||||
$data = wpcf_footer_credit_defaults();
|
||||
shuffle($data);
|
||||
$message = rand(0, count($data));
|
||||
$check = defined('WPCF_SRC') && WPCF_SRC == 'wporg' ? 0 : 1;
|
||||
foreach ($options as $option) {
|
||||
$option = get_option($option, false);
|
||||
if ($option != false) {
|
||||
$check = false;
|
||||
$active = get_option('wpcf_footer_credit', false);
|
||||
if ($active == false) {
|
||||
update_option('wpcf_footer_credit',
|
||||
array('active' => 0, 'message' => $message));
|
||||
}
|
||||
return $check;
|
||||
break;
|
||||
}
|
||||
}
|
||||
update_option('wpcf_footer_credit',
|
||||
array('active' => $check, 'message' => $message));
|
||||
return $check;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default credits.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function wpcf_footer_credit_defaults() {
|
||||
return array(
|
||||
sprintf(__("Functionality enhanced using %sWordPress Custom Fields%s",
|
||||
'wpcf'),
|
||||
'<a href="http://wp-types.com/documentation/user-guides/using-custom-fields/" target="_blank">',
|
||||
' »</a>'),
|
||||
sprintf(__("Functionality enhanced using %sWordPress Custom Post Types%s",
|
||||
'wpcf'),
|
||||
'<a href="http://wp-types.com/documentation/user-guides/create-a-custom-post-type/" target="_blank">',
|
||||
' »</a>'),
|
||||
sprintf(__("Functionality enhanced using %sWordPress Custom Taxonomy%s",
|
||||
'wpcf'),
|
||||
'<a href="http://wp-types.com/documentation/user-guides/create-custom-taxonomies/" target="_blank">',
|
||||
' »</a>'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders credits in footer.
|
||||
*/
|
||||
function wpcf_footer_credit_render() {
|
||||
$active = defined('WPCF_SRC') && WPCF_SRC == 'wporg' ? 0 : 1;
|
||||
$option = get_option('wpcf_footer_credit', array('active' => $active));
|
||||
// Set message
|
||||
$data = wpcf_footer_credit_defaults();
|
||||
if (isset($option['message']) && isset($data[$option['message']])) {
|
||||
$message = $data[$option['message']];
|
||||
} else {
|
||||
$message = $data[0];
|
||||
}
|
||||
$template = get_template();
|
||||
if ($template == 'canvas') {
|
||||
echo '<p style="margin-bottom:10px;">' . $message . '</p>';
|
||||
} else if ($template == 'genesis') {
|
||||
echo '<div id="types-credits" class="creds"><p>' . $message . '</p></div>';
|
||||
} else if ($template == 'thesis_18') {
|
||||
echo '<p>' . $message . '</p>';
|
||||
} else if ($template == 'headway') {
|
||||
echo '<p style="float:none;" class="footer-left footer-headway-link footer-link">' . $message . '</p>';
|
||||
} else if ($template == 'twentyeleven') {
|
||||
echo $message . '<br />';
|
||||
} else if ($template == 'twentyten') {
|
||||
echo str_replace('<a ', '<a style="background:none;" ', $message) . '<br />';
|
||||
} else {
|
||||
echo '<div id="types-credits" style="margin: 10px 0 10px 0;width:95%;text-align:center;font-size:0.9em;">' . $message . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Support message init.
|
||||
*/
|
||||
function wpcf_footer_credit_message_init() {
|
||||
wp_enqueue_script('wpcf-footer-credit', WPCF_RES_RELPATH . '/js/basic.js',
|
||||
array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable'),
|
||||
WPCF_VERSION);
|
||||
add_action('admin_notices', 'wpcf_footer_credit_message');
|
||||
}
|
||||
|
||||
/**
|
||||
* Support message.
|
||||
*/
|
||||
function wpcf_footer_credit_message() {
|
||||
$dismissed = get_option('wpcf_dismissed_messages', array());
|
||||
if (in_array('footer_credit_support_message', $dismissed)) {
|
||||
return false;
|
||||
}
|
||||
$option = get_option('wpcf_footer_credit', array('active' => 0));
|
||||
if (defined('WPCF_SRC') && WPCF_SRC == 'wporg' && empty($option['active'])) {
|
||||
$message = __('You too can support Types! Would you like to add a small credit link, saying that you\'re using Types for custom fields or custom post types?',
|
||||
'wpcf')
|
||||
. '<br /><br />'
|
||||
. '<a onclick="jQuery(this).parent().parent().fadeOut();" class="wpcf-ajax-link button-primary" href="'
|
||||
. admin_url('admin-ajax.php?action=wpcf_ajax&wpcf_action=footer_credit_activate_message&_wpnonce='
|
||||
. wp_create_nonce('footer_credit_activate_message')) . '" class="button-primary">' . __('Yes', 'wpcf') . '</a>'
|
||||
. " <a onclick=\"jQuery(this).parent().parent().fadeOut();\" class=\"wpcf-ajax-link button-secondary\" href=\""
|
||||
. admin_url('admin-ajax.php?action=wpcf_ajax&wpcf_action=dismiss_message&id='
|
||||
. 'footer_credit_support_message' . '&_wpnonce=' . wp_create_nonce('dismiss_message')) . "\">"
|
||||
. __('No, thanks', 'wpcf') . '</a>';
|
||||
echo '<div class="message updated"><p>' . $message . '</p></div>';
|
||||
}
|
||||
}
|
||||
@ -1,406 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Import/export data.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Imports data from XML.
|
||||
*/
|
||||
function wpcf_admin_import_data($data = '', $redirect = true) {
|
||||
global $wpdb;
|
||||
|
||||
libxml_use_internal_errors(true);
|
||||
$data = simplexml_load_string($data);
|
||||
if (!$data) {
|
||||
echo '<div class="message error"><p>' . __('Error parsing XML', 'wpcf') . '</p></div>';
|
||||
foreach (libxml_get_errors() as $error) {
|
||||
echo '<div class="message error"><p>' . $error->message . '</p></div>';
|
||||
}
|
||||
libxml_clear_errors();
|
||||
return false;
|
||||
}
|
||||
$overwrite_groups = isset($_POST['overwrite-groups']);
|
||||
$overwrite_fields = isset($_POST['overwrite-fields']);
|
||||
$overwrite_types = isset($_POST['overwrite-types']);
|
||||
$overwrite_tax = isset($_POST['overwrite-tax']);
|
||||
$delete_groups = isset($_POST['delete-groups']);
|
||||
$delete_fields = isset($_POST['delete-fields']);
|
||||
$delete_types = isset($_POST['delete-types']);
|
||||
$delete_tax = isset($_POST['delete-tax']);
|
||||
|
||||
// Process groups
|
||||
|
||||
if (!empty($data->groups)) {
|
||||
$groups = array();
|
||||
// Set insert data from XML
|
||||
foreach ($data->groups->group as $group) {
|
||||
$group = wpcf_admin_import_export_simplexml2array($group);
|
||||
$groups[$group['ID']] = $group;
|
||||
}
|
||||
// Set insert data from POST
|
||||
if (!empty($_POST['groups'])) {
|
||||
foreach ($_POST['groups'] as $group_id => $group) {
|
||||
if (empty($groups[$group_id])) {
|
||||
continue;
|
||||
}
|
||||
$groups[$group_id]['add'] = !empty($group['add']);
|
||||
$groups[$group_id]['update'] = (isset($group['update']) && $group['update'] == 'update') ? true : false;
|
||||
}
|
||||
} else {
|
||||
foreach ($groups as $group_id => $group) {
|
||||
$groups[$group_id]['add'] = true;
|
||||
$groups[$group_id]['update'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Insert groups
|
||||
$groups_check = array();
|
||||
foreach ($groups as $group_id => $group) {
|
||||
$post = array(
|
||||
'post_status' => $group['post_status'],
|
||||
'post_type' => 'wp-types-group',
|
||||
'post_title' => $group['post_title'],
|
||||
'post_content' => !empty($group['post_content']) ? $group['post_content'] : '',
|
||||
);
|
||||
if ((isset($group['add']) && $group['add'])) {
|
||||
$post_to_update = $wpdb->get_var($wpdb->prepare(
|
||||
"SELECT ID FROM $wpdb->posts
|
||||
WHERE post_title = %s AND post_type = %s",
|
||||
$group['post_title'], 'wp-types-group'));
|
||||
// Update (may be forced by bulk action)
|
||||
if ($group['update'] || ($overwrite_groups && !empty($post_to_update))) {
|
||||
if (!empty($post_to_update)) {
|
||||
$post['ID'] = $post_to_update;
|
||||
$group_wp_id = wp_update_post($post);
|
||||
if (!$group_wp_id) {
|
||||
wpcf_admin_message_store(sprintf(__('Group "%s" update failed',
|
||||
'wpcf'),
|
||||
$group['post_title']), 'error');
|
||||
} else {
|
||||
wpcf_admin_message_store(sprintf(__('Group "%s" updated',
|
||||
'wpcf'),
|
||||
$group['post_title']));
|
||||
}
|
||||
} else {
|
||||
wpcf_admin_message_store(sprintf(__('Group "%s" update failed',
|
||||
'wpcf'), $group['post_title']),
|
||||
'error');
|
||||
}
|
||||
} else { // Insert
|
||||
$group_wp_id = wp_insert_post($post, true);
|
||||
if (is_wp_error($group_wp_id)) {
|
||||
wpcf_admin_message_store(sprintf(__('Group "%s" insert failed',
|
||||
'wpcf'), $group['post_title']),
|
||||
'error');
|
||||
} else {
|
||||
wpcf_admin_message_store(sprintf(__('Group "%s" added',
|
||||
'wpcf'), $group['post_title']));
|
||||
}
|
||||
}
|
||||
// Update meta
|
||||
if (!empty($group['meta'])) {
|
||||
foreach ($group['meta'] as $meta_key => $meta_value) {
|
||||
update_post_meta($group_wp_id, $meta_key, $meta_value);
|
||||
}
|
||||
}
|
||||
$group_check[] = $group_wp_id;
|
||||
if (!empty($post_to_update)) {
|
||||
$group_check[] = $post_to_update;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Delete groups (forced, set in bulk actions)
|
||||
if ($delete_groups) {
|
||||
$groups_to_delete = get_posts('post_type=wp-types-group&status=null');
|
||||
if (!empty($groups_to_delete)) {
|
||||
foreach ($groups_to_delete as $group_to_delete) {
|
||||
if (!in_array($group_to_delete->ID, $group_check)) {
|
||||
$deleted = wp_delete_post($group_to_delete->ID, true);
|
||||
if (!$deleted) {
|
||||
wpcf_admin_message_store(sprintf(__('Group "%s" delete failed',
|
||||
'wpcf'),
|
||||
$group_to_delete->post_title),
|
||||
'error');
|
||||
} else {
|
||||
wpcf_admin_message_store(sprintf(__('Group "%s" deleted',
|
||||
'wpcf'),
|
||||
$group_to_delete->post_title));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { // If not forced, look in POST
|
||||
if (!empty($_POST['groups-to-be-deleted'])) {
|
||||
foreach ($_POST['groups-to-be-deleted'] as $group_to_delete) {
|
||||
$group_to_delete_post = get_post($group_to_delete);
|
||||
if (!empty($group_to_delete_post) && $group_to_delete_post->post_type == 'wp-types-group') {
|
||||
$deleted = wp_delete_post($group_to_delete, true);
|
||||
if (!$deleted) {
|
||||
wpcf_admin_message_store(sprintf(__('Group "%s" delete failed',
|
||||
'wpcf'),
|
||||
$group_to_delete_post->post_title),
|
||||
'error');
|
||||
} else {
|
||||
wpcf_admin_message_store(sprintf(__('Group "%s" deleted',
|
||||
'wpcf'),
|
||||
$group_to_delete_post->post_title));
|
||||
}
|
||||
} else {
|
||||
wpcf_admin_message_store(sprintf(__('Group "%s" delete failed',
|
||||
'wpcf'), $group_to_delete),
|
||||
'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process fields
|
||||
|
||||
if (!empty($data->fields)) {
|
||||
$fields_existing = wpcf_admin_fields_get_fields();
|
||||
$fields = array();
|
||||
$fields_check = array();
|
||||
// Set insert data from XML
|
||||
foreach ($data->fields->field as $field) {
|
||||
$field = wpcf_admin_import_export_simplexml2array($field);
|
||||
$fields[$field['id']] = $field;
|
||||
}
|
||||
// Set insert data from POST
|
||||
if (!empty($_POST['fields'])) {
|
||||
foreach ($_POST['fields'] as $field_id => $field) {
|
||||
if (empty($fields[$field_id])) {
|
||||
continue;
|
||||
}
|
||||
$fields[$field_id]['add'] = !empty($field['add']);
|
||||
$fields[$field_id]['update'] = (isset($field['update']) && $field['update'] == 'update') ? true : false;
|
||||
}
|
||||
}
|
||||
// Insert fields
|
||||
foreach ($fields as $field_id => $field) {
|
||||
if ((isset($field['add']) && !$field['add']) && !$overwrite_fields) {
|
||||
continue;
|
||||
}
|
||||
if (empty($field['id']) || empty($field['name']) || empty($field['slug'])) {
|
||||
continue;
|
||||
}
|
||||
$field_data = array();
|
||||
$field_data['id'] = $field['id'];
|
||||
$field_data['name'] = $field['name'];
|
||||
$field_data['description'] = isset($field['description']) ? $field['description'] : '';
|
||||
$field_data['type'] = $field['type'];
|
||||
$field_data['slug'] = $field['slug'];
|
||||
$field_data['data'] = (isset($field['data']) && is_array($field['data'])) ? $field['data'] : array();
|
||||
$fields_existing[$field_id] = $field_data;
|
||||
$fields_check[] = $field_id;
|
||||
|
||||
// WPML
|
||||
global $iclTranslationManagement;
|
||||
if (!empty($iclTranslationManagement) && isset($field['wpml_action'])) {
|
||||
$iclTranslationManagement->settings['custom_fields_translation'][wpcf_types_get_meta_prefix($field) . $field_id] = $field['wpml_action'];
|
||||
$iclTranslationManagement->save_settings();
|
||||
}
|
||||
|
||||
wpcf_admin_message_store(sprintf(__('Field "%s" added/updated',
|
||||
'wpcf'), $field['name']));
|
||||
}
|
||||
// Delete fields
|
||||
if ($delete_fields) {
|
||||
foreach ($fields_existing as $k => $v) {
|
||||
if (!empty($v['data']['controlled'])) {
|
||||
continue;
|
||||
}
|
||||
if (!in_array($k, $fields_check)) {
|
||||
wpcf_admin_message_store(sprintf(__('Field "%s" deleted',
|
||||
'wpcf'),
|
||||
$fields_existing[$k]['name']));
|
||||
unset($fields_existing[$k]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!empty($_POST['fields-to-be-deleted'])) {
|
||||
foreach ($_POST['fields-to-be-deleted'] as $field_to_delete) {
|
||||
wpcf_admin_message_store(sprintf(__('Field "%s" deleted',
|
||||
'wpcf'),
|
||||
$fields_existing[$field_to_delete]['name']));
|
||||
unset($fields_existing[$field_to_delete]);
|
||||
}
|
||||
}
|
||||
}
|
||||
update_option('wpcf-fields', $fields_existing);
|
||||
}
|
||||
|
||||
// Process types
|
||||
|
||||
if (!empty($data->types)) {
|
||||
$types_existing = get_option('wpcf-custom-types', array());
|
||||
$types = array();
|
||||
$types_check = array();
|
||||
// Set insert data from XML
|
||||
foreach ($data->types->type as $type) {
|
||||
$type = wpcf_admin_import_export_simplexml2array($type);
|
||||
$types[$type['id']] = $type;
|
||||
}
|
||||
// Set insert data from POST
|
||||
if (!empty($_POST['types'])) {
|
||||
foreach ($_POST['types'] as $type_id => $type) {
|
||||
if (empty($types[$type_id])) {
|
||||
continue;
|
||||
}
|
||||
$types[$type_id]['add'] = !empty($type['add']);
|
||||
$types[$type_id]['update'] = (isset($type['update']) && $type['update'] == 'update') ? true : false;
|
||||
}
|
||||
}
|
||||
// Insert types
|
||||
foreach ($types as $type_id => $type) {
|
||||
if ((isset($type['add']) && !$type['add']) && !$overwrite_types) {
|
||||
continue;
|
||||
}
|
||||
unset($type['add'], $type['update']);
|
||||
$types_existing[$type_id] = $type;
|
||||
$types_check[] = $type_id;
|
||||
wpcf_admin_message_store(sprintf(__('Custom post type "%s" added/updated',
|
||||
'wpcf'), $type_id));
|
||||
}
|
||||
// Delete types
|
||||
if ($delete_types) {
|
||||
foreach ($types_existing as $k => $v) {
|
||||
if (!in_array($k, $types_check)) {
|
||||
unset($types_existing[$k]);
|
||||
wpcf_admin_message_store(sprintf(__('Custom post type "%s" deleted',
|
||||
'wpcf'), esc_html($k)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!empty($_POST['types-to-be-deleted'])) {
|
||||
foreach ($_POST['types-to-be-deleted'] as $type_to_delete) {
|
||||
wpcf_admin_message_store(sprintf(__('Custom post type "%s" deleted',
|
||||
'wpcf'),
|
||||
$types_existing[$type_to_delete]['labels']['name']));
|
||||
unset($types_existing[$type_to_delete]);
|
||||
}
|
||||
}
|
||||
}
|
||||
update_option('wpcf-custom-types', $types_existing);
|
||||
}
|
||||
|
||||
// Process taxonomies
|
||||
|
||||
if (!empty($data->taxonomies)) {
|
||||
$taxonomies_existing = get_option('wpcf-custom-taxonomies', array());
|
||||
$taxonomies = array();
|
||||
$taxonomies_check = array();
|
||||
// Set insert data from XML
|
||||
foreach ($data->taxonomies->taxonomy as $taxonomy) {
|
||||
$taxonomy = wpcf_admin_import_export_simplexml2array($taxonomy);
|
||||
$taxonomies[$taxonomy['id']] = $taxonomy;
|
||||
}
|
||||
// Set insert data from POST
|
||||
if (!empty($_POST['taxonomies'])) {
|
||||
foreach ($_POST['taxonomies'] as $taxonomy_id => $taxonomy) {
|
||||
if (empty($taxonomies[$taxonomy_id])) {
|
||||
continue;
|
||||
}
|
||||
$taxonomies[$taxonomy_id]['add'] = !empty($taxonomy['add']);
|
||||
$taxonomies[$taxonomy_id]['update'] = (isset($taxonomy['update']) && $taxonomy['update'] == 'update') ? true : false;
|
||||
}
|
||||
}
|
||||
// Insert taxonomies
|
||||
foreach ($taxonomies as $taxonomy_id => $taxonomy) {
|
||||
if ((isset($taxonomy['add']) && !$taxonomy['add']) && !$overwrite_tax) {
|
||||
continue;
|
||||
}
|
||||
unset($taxonomy['add'], $taxonomy['update']);
|
||||
$taxonomies_existing[$taxonomy_id] = $taxonomy;
|
||||
$taxonomies_check[] = $taxonomy_id;
|
||||
wpcf_admin_message_store(sprintf(__('Custom taxonomy "%s" added/updated',
|
||||
'wpcf'), $taxonomy_id));
|
||||
}
|
||||
// Delete taxonomies
|
||||
if ($delete_tax) {
|
||||
foreach ($taxonomies_existing as $k => $v) {
|
||||
if (!in_array($k, $taxonomies_check)) {
|
||||
unset($taxonomies_existing[$k]);
|
||||
wpcf_admin_message_store(sprintf(__('Custom taxonomy "%s" deleted',
|
||||
'wpcf'), $k));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!empty($_POST['taxonomies-to-be-deleted'])) {
|
||||
foreach ($_POST['taxonomies-to-be-deleted'] as $taxonomy_to_delete) {
|
||||
wpcf_admin_message_store(sprintf(__('Custom taxonomy "%s" deleted',
|
||||
'wpcf'),
|
||||
$taxonomies_existing[$taxonomy_to_delete]['labels']['name']));
|
||||
unset($taxonomies_existing[$taxonomy_to_delete]);
|
||||
}
|
||||
}
|
||||
}
|
||||
update_option('wpcf-custom-taxonomies', $taxonomies_existing);
|
||||
}
|
||||
|
||||
// Add relationships
|
||||
if (!empty($data->post_relationships) && !empty($_POST['post_relationship'])) {
|
||||
$relationship_existing = get_option('wpcf_post_relationship', array());
|
||||
foreach ($data->post_relationships->post_relationship as $relationship) {
|
||||
$relationship = unserialize($relationship);
|
||||
$relationship = array_merge($relationship_existing, $relationship);
|
||||
update_option('wpcf_post_relationship', $relationship);
|
||||
wpcf_admin_message_store(__('Post relationships created', 'wpcf'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// WPML bulk registration
|
||||
if (wpcf_get_settings('register_translations_on_import')) {
|
||||
wpcf_admin_bulk_string_translation();
|
||||
}
|
||||
|
||||
// Flush rewrite rules
|
||||
wpcf_init_custom_types_taxonomies();
|
||||
flush_rewrite_rules();
|
||||
|
||||
if ($redirect) {
|
||||
echo '<script type="text/javascript">
|
||||
<!--
|
||||
window.location = "' . admin_url('admin.php?page=wpcf-import-export') . '"
|
||||
//-->
|
||||
</script>';
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loops over elements and convert to array or empty string.
|
||||
*
|
||||
* @param type $element
|
||||
* @return string
|
||||
*/
|
||||
function wpcf_admin_import_export_simplexml2array($element) {
|
||||
$element = is_string($element) ? trim($element) : $element;
|
||||
if (!empty($element) && is_object($element)) {
|
||||
$element = (array) $element;
|
||||
}
|
||||
if (empty($element)) {
|
||||
$element = '';
|
||||
} else if (is_array($element)) {
|
||||
foreach ($element as $k => $v) {
|
||||
$v = is_string($v) ? trim($v) : $v;
|
||||
if (empty($v)) {
|
||||
$element[$k] = '';
|
||||
continue;
|
||||
}
|
||||
$add = wpcf_admin_import_export_simplexml2array($v);
|
||||
if (!empty($add)) {
|
||||
$element[$k] = $add;
|
||||
} else {
|
||||
$element[$k] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($element)) {
|
||||
$element = '';
|
||||
}
|
||||
|
||||
return $element;
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
The Embedded version lets you create custom types, taxonomy and fields for your theme or plugin, without requiring any plugin.
|
||||
|
||||
= Instructions =
|
||||
|
||||
1. Create the directory called 'embedded-types' in the root folder of your theme or plugin.
|
||||
|
||||
2. Copy the entire content of this directory (embedded) to the 'embedded-types' that you just created.
|
||||
|
||||
3. Include them from the theme’s functions.php file by adding these statements at the very beginning (right after the php statement):
|
||||
|
||||
require_once dirname(__FILE__) . '/embedded-types/types.php';
|
||||
|
||||
4. Export your configuration from your development site. Go to the Types->Import/Export menu and click on the 'Export' button. You will receive a ZIP file with the XML and PHP configuration files (both are required).
|
||||
|
||||
Unzip that file and place both settings.xml and the setting.php into the embedded-types directory.
|
||||
|
||||
|
||||
You're done!
|
||||
@ -1,303 +0,0 @@
|
||||
#icon-wpcf {
|
||||
background: url(../images/logo-32.png) no-repeat;
|
||||
}
|
||||
.wpcf-ajax-loading {
|
||||
background: url(../images/ajax-loader-big.gif) no-repeat;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
}
|
||||
.wpcf-ajax-loading-small {
|
||||
background: url(../images/ajax-loader-small.gif) no-repeat;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
/* FORMS */
|
||||
.wpcf-form-fieldset {
|
||||
background-color: #ffffff;
|
||||
padding: 0 15px 15px 15px;
|
||||
border: 1px solid #cccccc;
|
||||
border-color: #cccccc;
|
||||
margin: 15px 0 25px 0;
|
||||
}
|
||||
.wpcf-form-fieldset fieldset {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.wpcf-fields-form fieldset {
|
||||
width: auto;
|
||||
}
|
||||
.wpcf-form-fieldset legend {
|
||||
font-weight: bold;
|
||||
}
|
||||
.wpcf-form-fieldset .legend-collapsed {
|
||||
padding-left: 15px;
|
||||
background-image: url(../images/expand.png);
|
||||
background-repeat: no-repeat;
|
||||
background-position: 0px 2px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.wpcf-form-fieldset .legend-expanded {
|
||||
padding-left: 15px;
|
||||
background-image: url(../images/collapse.png);
|
||||
background-repeat: no-repeat;
|
||||
background-position: 0px 3px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.wpcf-form-fieldset .collapsed {
|
||||
display: none;
|
||||
}
|
||||
.wpcf-form-item {
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
.wpcf-form-fieldset .wpcf-form-item:first-child {
|
||||
margin-top: 5px;
|
||||
}
|
||||
.wpcf-form-item .wpcf-form-item {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.wpcf-form-submit {
|
||||
margin-top: 15px;
|
||||
}
|
||||
.wpcf-form-description {
|
||||
font-size: 0.85em;
|
||||
font-style: italic;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.wpcf-form-description-fieldset {
|
||||
font-size: 1em;
|
||||
font-style: normal;
|
||||
margin: 10px 0;
|
||||
}
|
||||
.wpcf-form-textarea {
|
||||
width: 100%;
|
||||
}
|
||||
.wpcf-form-description-textarea,
|
||||
.wpcf-form-description-checkboxes,
|
||||
.wpcf-form-description-radios {
|
||||
font-size: 1em;
|
||||
font-style: normal;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.wpcf-form-label {
|
||||
white-space: nowrap;
|
||||
}
|
||||
.wpcf-form-textfield-label {
|
||||
font-size: 1em;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
}
|
||||
.wpcf-form-textfield {
|
||||
width: 200px;
|
||||
}
|
||||
.wpcf-form-item-file label {
|
||||
font-size: 1em;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
}
|
||||
.wpcf-form-item-textarea label,
|
||||
.wpcf-form-title-checkboxes,
|
||||
.wpcf-form-title-radios,
|
||||
.wpcf-form-select-label {
|
||||
font-size: 1em;
|
||||
font-weight: bold;
|
||||
}
|
||||
.wpcf-form-item-textarea label {
|
||||
display: block;
|
||||
}
|
||||
.wpcf-form-error {
|
||||
background-color: #ffffe0;
|
||||
border: 1px solid #e6db55;
|
||||
padding: 5px 10px;
|
||||
width: auto;
|
||||
margin: 10px 0;
|
||||
display: block;
|
||||
}
|
||||
input.wpcf-form-error {
|
||||
background-color: #F8F8F8;
|
||||
}
|
||||
.wpcf-form-fields-align-right {
|
||||
float: left;
|
||||
width: 250px;
|
||||
margin-top: 0;
|
||||
margin-left: 450px;
|
||||
/* position: absolute;*/
|
||||
position: fixed;
|
||||
/* THIS IS ALSO SET IN JS AFTER ADDING SCROLL */
|
||||
clear: both;
|
||||
}
|
||||
.wpcf-form-fields-align-right fieldset {
|
||||
width: 250px;
|
||||
}
|
||||
.wpcf-form-fields-align-right a.wpcf-fields-add-ajax-link {
|
||||
/* line-height: 30px;*/
|
||||
margin: 3px 5px 2px 0;
|
||||
height: 15px;
|
||||
float: left;
|
||||
}
|
||||
.wpcf-fields-form .ui-draggable .wpcf-form-fieldset .wpcf-form-fieldset legend {
|
||||
cursor: pointer;
|
||||
}
|
||||
.wpcf-fields-form .ui-sortable {
|
||||
padding: 0 0 10px 0;
|
||||
}
|
||||
.wpcf-fields-form .ui-sortable-placeholder {
|
||||
border: 1px dashed #CCCCCC;
|
||||
width: auto;
|
||||
visibility: visible !important;
|
||||
}
|
||||
.wpcf-form-fields-delete,
|
||||
.wpcf-fields-form-move-field {
|
||||
float: left;
|
||||
margin-top: 10px;
|
||||
margin-top: 3px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
.wpcf-fields-form-move-field {
|
||||
cursor: move;
|
||||
}
|
||||
.wpcf-fields-form .taxonomy-title {
|
||||
margin-top: 10px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* LIST */
|
||||
#wpcf_groups_list th {
|
||||
white-space: nowrap;
|
||||
}
|
||||
#wpcf-table-group_name {
|
||||
width: 250px;
|
||||
}
|
||||
#wpcf-table-group_taxonomies {
|
||||
width: 200px;
|
||||
}
|
||||
#wpcf-form-fields-main {
|
||||
width: 400px;
|
||||
}
|
||||
|
||||
/* STRANGE */
|
||||
#ui-datepicker-div {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.wpcf-shortcode {
|
||||
margin-top: 5px;
|
||||
}
|
||||
.wpcf-pointer {
|
||||
cursor: pointer;
|
||||
}
|
||||
.wpcf-fields-form-validate-table {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
border: 1px solid #D2D2D2;
|
||||
}
|
||||
.wpcf-fields-form-validate-table td {
|
||||
padding: 5px 10px;
|
||||
margin: 0;
|
||||
}
|
||||
.wpcf-fields-form-validate-table thead tr {
|
||||
background-color: #E8E8E8;
|
||||
font-weight: bold;
|
||||
}
|
||||
.wpcf-fields-form-validate-table thead td {
|
||||
border-bottom: 1px solid #D2D2D2;
|
||||
}
|
||||
.wpcf-fields-form-validate-table tbody tr:nth-child(odd) {
|
||||
background-color: #F7F7F7;
|
||||
}
|
||||
.wpcf-fields-form-validate-table tbody tr:nth-child(even) {
|
||||
background-color: #EEEEEE;
|
||||
}
|
||||
.wpcf-fields-form-validate-table td .textfield{
|
||||
width: 100%;
|
||||
}
|
||||
.wpcf-fields-form-radio-move-field {
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
/* TYPES FORM */
|
||||
#wpcf-types-form-name-table,
|
||||
#wpcf-types-form-visibility-table,
|
||||
#wpcf-types-form-labels-table,
|
||||
#wpcf-types-form-taxonomies-table,
|
||||
#wpcf-types-form-supports-table,
|
||||
.wpcf-types-form-table {
|
||||
margin-bottom: 20px;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
#wpcf-types-form-name-table td,
|
||||
#wpcf-types-form-visibility-table td,
|
||||
#wpcf-types-form-labels-table td,
|
||||
#wpcf-types-form-taxonomies-table td,
|
||||
#wpcf-types-form-supports-table td,
|
||||
.wpcf-types-form-table td {
|
||||
border: none;
|
||||
}
|
||||
#wpcf-types-form-name-table tbody tr td:first-child {
|
||||
text-align: right;
|
||||
}
|
||||
#wpcf-types-form-name-table tbody tr:first-child td {
|
||||
padding-top: 10px;
|
||||
}
|
||||
#wpcf-types-form-name-table input {
|
||||
width: 100%;
|
||||
}
|
||||
#wpcf-types-form-name-table label {
|
||||
font-weight: normal;
|
||||
}
|
||||
#wpcf-types-form-visibility-table tbody table {
|
||||
margin-top: 5px;
|
||||
}
|
||||
#wpcf-types-form-visibility-table tbody table td {
|
||||
padding: 0;
|
||||
vertical-align: middle;
|
||||
}
|
||||
#wpcf-types-form-visibility-table tbody table tr td:first-child {
|
||||
text-align: right;
|
||||
}
|
||||
#wpcf-types-form-visibility-table tbody table label {
|
||||
font-weight: normal;
|
||||
}
|
||||
#wpcf-types-form-labels-table tbody tr td:first-child {
|
||||
text-align: right;
|
||||
}
|
||||
#wpcf-types-form-labels-table tbody label {
|
||||
font-weight: normal;
|
||||
}
|
||||
#wpcf-types-form-labels-table tbody td {
|
||||
vertical-align: middle;
|
||||
}
|
||||
#wpcf-types-form-labels-table .wpcf-form-description {
|
||||
font-size: 0.9em;
|
||||
line-height: 1.2em;
|
||||
}
|
||||
#wpcf-types-form-labels-table tbody tr:first-child td {
|
||||
padding-top: 15px;
|
||||
}
|
||||
#wpcf-types-form-rewrite-toggle {
|
||||
margin: 0 0 20px 0;
|
||||
}
|
||||
/*CHECKBOXES*/
|
||||
.wpcf-checkboxes-drag {
|
||||
position: absolute;
|
||||
}
|
||||
.wpcf-checkboxes-drag img {
|
||||
cursor: pointer;
|
||||
}
|
||||
.wpcf-fields-checkboxes-draggable legend {
|
||||
background-position: 15px 2px !important;
|
||||
background-repeat: no-repeat;
|
||||
cursor: pointer;
|
||||
padding-left: 30px !important;
|
||||
}
|
||||
.wpcf-message {
|
||||
padding: 0 0.6em;
|
||||
border-radius: 3px 3px 3px 3px;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
margin: 1em 0 1em 0;
|
||||
}
|
||||
.wpcf-error {
|
||||
background-color: #FFEBE8;
|
||||
border-color: #CC0000;
|
||||
}
|
||||
@ -1,73 +0,0 @@
|
||||
.wpcf-form-label {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.wpcf-form-description {
|
||||
margin: 5px 0;
|
||||
font-size: 1em;
|
||||
}
|
||||
img.ui-datepicker-trigger {
|
||||
margin-left: 5px;
|
||||
}
|
||||
#poststuff .inside .wpcf-meta-box-description p {
|
||||
margin: 5px 0 15px 0;
|
||||
}
|
||||
#poststuff .inside .wpcf-form-item:last-child {
|
||||
/* margin-bottom: 0;*/
|
||||
}
|
||||
/*#poststuff .inside .wpcf-form-item .wpcf-form-item:last-child {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
#poststuff .inside .form-item-radios:last-child {
|
||||
margin-bottom: 15px !important;
|
||||
}*/
|
||||
.wpcf-fields-file-preview {
|
||||
/* float: left;*/
|
||||
/* margin-right: 10px;*/
|
||||
/* margin: -30px 0 30px 0;*/
|
||||
}
|
||||
.wpcf-fields-file-preview img {
|
||||
margin-top: 10px;
|
||||
height: 50px;
|
||||
width: auto;
|
||||
border: 1px solid #A0A0A0;
|
||||
}
|
||||
.wpcf-form-textfield,
|
||||
.wpcf-form-textarea {
|
||||
width: 100%;
|
||||
}
|
||||
.wpcf-fields-file-textfield {
|
||||
width: 70%;
|
||||
}
|
||||
#side-info-column .wpcf-fields-file-textfield {
|
||||
width: 130px;
|
||||
}
|
||||
.wpcf-repetitive-response {
|
||||
margin-top: 20px;
|
||||
}
|
||||
.wpcf-repetitive-response .form-item,
|
||||
.wpcf-skype {
|
||||
margin-bottom: 40px !important;
|
||||
}
|
||||
.wpcf-repetitive-response .wpcf-form-item-radio {
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
.wpcf-repetitive-buttons {
|
||||
float: right;
|
||||
position: relative;
|
||||
top: -10px;
|
||||
}
|
||||
.wpcf-message {
|
||||
padding: 0 0.6em;
|
||||
border-radius: 3px 3px 3px 3px;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
margin: 1em 0 1em 0;
|
||||
}
|
||||
.wpcf-error {
|
||||
background-color: #FFEBE8;
|
||||
border-color: #CC0000;
|
||||
}
|
||||
.wpcf-pr-table-wrapper {
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
}
|
||||
@ -1,357 +0,0 @@
|
||||
/*
|
||||
* jQuery UI CSS Framework 1.8.14
|
||||
*
|
||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
* http://jquery.org/license
|
||||
*
|
||||
* http://docs.jquery.com/UI/Theming/API
|
||||
*/
|
||||
|
||||
/* Layout helpers
|
||||
----------------------------------*/
|
||||
.ui-helper-hidden { display: none; }
|
||||
.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); }
|
||||
.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; }
|
||||
.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
|
||||
.ui-helper-clearfix { display: inline-block; }
|
||||
/* required comment for clearfix to work in Opera \*/
|
||||
* html .ui-helper-clearfix { height:1%; }
|
||||
.ui-helper-clearfix { display:block; }
|
||||
/* end clearfix */
|
||||
.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); }
|
||||
|
||||
|
||||
/* Interaction Cues
|
||||
----------------------------------*/
|
||||
.ui-state-disabled { cursor: default !important; }
|
||||
|
||||
|
||||
/* Icons
|
||||
----------------------------------*/
|
||||
|
||||
/* states and images */
|
||||
.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }
|
||||
|
||||
|
||||
/* Misc visuals
|
||||
----------------------------------*/
|
||||
|
||||
/* Overlays */
|
||||
.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
|
||||
|
||||
|
||||
/*
|
||||
* jQuery UI CSS Framework 1.8.14
|
||||
*
|
||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
* http://jquery.org/license
|
||||
*
|
||||
* http://docs.jquery.com/UI/Theming/API
|
||||
*
|
||||
* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Trebuchet%20MS,%20Tahoma,%20Verdana,%20Arial,%20sans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=f6a828&bgTextureHeader=12_gloss_wave.png&bgImgOpacityHeader=35&borderColorHeader=e78f08&fcHeader=ffffff&iconColorHeader=ffffff&bgColorContent=eeeeee&bgTextureContent=03_highlight_soft.png&bgImgOpacityContent=100&borderColorContent=dddddd&fcContent=333333&iconColorContent=222222&bgColorDefault=f6f6f6&bgTextureDefault=02_glass.png&bgImgOpacityDefault=100&borderColorDefault=cccccc&fcDefault=1c94c4&iconColorDefault=ef8c08&bgColorHover=fdf5ce&bgTextureHover=02_glass.png&bgImgOpacityHover=100&borderColorHover=fbcb09&fcHover=c77405&iconColorHover=ef8c08&bgColorActive=ffffff&bgTextureActive=02_glass.png&bgImgOpacityActive=65&borderColorActive=fbd850&fcActive=eb8f00&iconColorActive=ef8c08&bgColorHighlight=ffe45c&bgTextureHighlight=03_highlight_soft.png&bgImgOpacityHighlight=75&borderColorHighlight=fed22f&fcHighlight=363636&iconColorHighlight=228ef1&bgColorError=b81900&bgTextureError=08_diagonals_thick.png&bgImgOpacityError=18&borderColorError=cd0a0a&fcError=ffffff&iconColorError=ffd27a&bgColorOverlay=666666&bgTextureOverlay=08_diagonals_thick.png&bgImgOpacityOverlay=20&opacityOverlay=50&bgColorShadow=000000&bgTextureShadow=01_flat.png&bgImgOpacityShadow=10&opacityShadow=20&thicknessShadow=5px&offsetTopShadow=-5px&offsetLeftShadow=-5px&cornerRadiusShadow=5px
|
||||
*/
|
||||
|
||||
|
||||
/* Component containers
|
||||
----------------------------------*/
|
||||
.ui-widget { font-family: Trebuchet MS, Tahoma, Verdana, Arial, sans-serif; font-size: 1.1em; }
|
||||
.ui-widget .ui-widget { font-size: 1em; }
|
||||
.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Trebuchet MS, Tahoma, Verdana, Arial, sans-serif; font-size: 1em; }
|
||||
.ui-widget-content { border: 1px solid #dddddd; background: #eeeeee url(images/ui-bg_highlight-soft_100_eeeeee_1x100.png) 50% top repeat-x; color: #333333; }
|
||||
.ui-widget-content a { color: #333333; }
|
||||
.ui-widget-header { border: 1px solid #e78f08; background: #f6a828 url(images/ui-bg_gloss-wave_35_f6a828_500x100.png) 50% 50% repeat-x; color: #ffffff; font-weight: bold; }
|
||||
.ui-widget-header a { color: #ffffff; }
|
||||
|
||||
/* Interaction states
|
||||
----------------------------------*/
|
||||
.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #cccccc; background: #f6f6f6 url(images/ui-bg_glass_100_f6f6f6_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #1c94c4; }
|
||||
.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #1c94c4; text-decoration: none; }
|
||||
.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #fbcb09; background: #fdf5ce url(images/ui-bg_glass_100_fdf5ce_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #c77405; }
|
||||
.ui-state-hover a, .ui-state-hover a:hover { color: #c77405; text-decoration: none; }
|
||||
.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #fbd850; background: #ffffff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #eb8f00; }
|
||||
.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #eb8f00; text-decoration: none; }
|
||||
.ui-widget :active { outline: none; }
|
||||
|
||||
/* Interaction Cues
|
||||
----------------------------------*/
|
||||
.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #fed22f; background: #ffe45c url(images/ui-bg_highlight-soft_75_ffe45c_1x100.png) 50% top repeat-x; color: #363636; }
|
||||
.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #363636; }
|
||||
.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a; background: #b81900 url(images/ui-bg_diagonals-thick_18_b81900_40x40.png) 50% 50% repeat; color: #ffffff; }
|
||||
.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #ffffff; }
|
||||
.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #ffffff; }
|
||||
.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; }
|
||||
.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; }
|
||||
.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; }
|
||||
|
||||
/* Icons
|
||||
----------------------------------*/
|
||||
|
||||
/* states and images */
|
||||
.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png); }
|
||||
.ui-widget-content .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); }
|
||||
.ui-widget-header .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); }
|
||||
.ui-state-default .ui-icon { background-image: url(images/ui-icons_ef8c08_256x240.png); }
|
||||
.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_ef8c08_256x240.png); }
|
||||
.ui-state-active .ui-icon {background-image: url(images/ui-icons_ef8c08_256x240.png); }
|
||||
.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_228ef1_256x240.png); }
|
||||
.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_ffd27a_256x240.png); }
|
||||
|
||||
/* positioning */
|
||||
.ui-icon-carat-1-n { background-position: 0 0; }
|
||||
.ui-icon-carat-1-ne { background-position: -16px 0; }
|
||||
.ui-icon-carat-1-e { background-position: -32px 0; }
|
||||
.ui-icon-carat-1-se { background-position: -48px 0; }
|
||||
.ui-icon-carat-1-s { background-position: -64px 0; }
|
||||
.ui-icon-carat-1-sw { background-position: -80px 0; }
|
||||
.ui-icon-carat-1-w { background-position: -96px 0; }
|
||||
.ui-icon-carat-1-nw { background-position: -112px 0; }
|
||||
.ui-icon-carat-2-n-s { background-position: -128px 0; }
|
||||
.ui-icon-carat-2-e-w { background-position: -144px 0; }
|
||||
.ui-icon-triangle-1-n { background-position: 0 -16px; }
|
||||
.ui-icon-triangle-1-ne { background-position: -16px -16px; }
|
||||
.ui-icon-triangle-1-e { background-position: -32px -16px; }
|
||||
.ui-icon-triangle-1-se { background-position: -48px -16px; }
|
||||
.ui-icon-triangle-1-s { background-position: -64px -16px; }
|
||||
.ui-icon-triangle-1-sw { background-position: -80px -16px; }
|
||||
.ui-icon-triangle-1-w { background-position: -96px -16px; }
|
||||
.ui-icon-triangle-1-nw { background-position: -112px -16px; }
|
||||
.ui-icon-triangle-2-n-s { background-position: -128px -16px; }
|
||||
.ui-icon-triangle-2-e-w { background-position: -144px -16px; }
|
||||
.ui-icon-arrow-1-n { background-position: 0 -32px; }
|
||||
.ui-icon-arrow-1-ne { background-position: -16px -32px; }
|
||||
.ui-icon-arrow-1-e { background-position: -32px -32px; }
|
||||
.ui-icon-arrow-1-se { background-position: -48px -32px; }
|
||||
.ui-icon-arrow-1-s { background-position: -64px -32px; }
|
||||
.ui-icon-arrow-1-sw { background-position: -80px -32px; }
|
||||
.ui-icon-arrow-1-w { background-position: -96px -32px; }
|
||||
.ui-icon-arrow-1-nw { background-position: -112px -32px; }
|
||||
.ui-icon-arrow-2-n-s { background-position: -128px -32px; }
|
||||
.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; }
|
||||
.ui-icon-arrow-2-e-w { background-position: -160px -32px; }
|
||||
.ui-icon-arrow-2-se-nw { background-position: -176px -32px; }
|
||||
.ui-icon-arrowstop-1-n { background-position: -192px -32px; }
|
||||
.ui-icon-arrowstop-1-e { background-position: -208px -32px; }
|
||||
.ui-icon-arrowstop-1-s { background-position: -224px -32px; }
|
||||
.ui-icon-arrowstop-1-w { background-position: -240px -32px; }
|
||||
.ui-icon-arrowthick-1-n { background-position: 0 -48px; }
|
||||
.ui-icon-arrowthick-1-ne { background-position: -16px -48px; }
|
||||
.ui-icon-arrowthick-1-e { background-position: -32px -48px; }
|
||||
.ui-icon-arrowthick-1-se { background-position: -48px -48px; }
|
||||
.ui-icon-arrowthick-1-s { background-position: -64px -48px; }
|
||||
.ui-icon-arrowthick-1-sw { background-position: -80px -48px; }
|
||||
.ui-icon-arrowthick-1-w { background-position: -96px -48px; }
|
||||
.ui-icon-arrowthick-1-nw { background-position: -112px -48px; }
|
||||
.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; }
|
||||
.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; }
|
||||
.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; }
|
||||
.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; }
|
||||
.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; }
|
||||
.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; }
|
||||
.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; }
|
||||
.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; }
|
||||
.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; }
|
||||
.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; }
|
||||
.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; }
|
||||
.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; }
|
||||
.ui-icon-arrowreturn-1-w { background-position: -64px -64px; }
|
||||
.ui-icon-arrowreturn-1-n { background-position: -80px -64px; }
|
||||
.ui-icon-arrowreturn-1-e { background-position: -96px -64px; }
|
||||
.ui-icon-arrowreturn-1-s { background-position: -112px -64px; }
|
||||
.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; }
|
||||
.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; }
|
||||
.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; }
|
||||
.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; }
|
||||
.ui-icon-arrow-4 { background-position: 0 -80px; }
|
||||
.ui-icon-arrow-4-diag { background-position: -16px -80px; }
|
||||
.ui-icon-extlink { background-position: -32px -80px; }
|
||||
.ui-icon-newwin { background-position: -48px -80px; }
|
||||
.ui-icon-refresh { background-position: -64px -80px; }
|
||||
.ui-icon-shuffle { background-position: -80px -80px; }
|
||||
.ui-icon-transfer-e-w { background-position: -96px -80px; }
|
||||
.ui-icon-transferthick-e-w { background-position: -112px -80px; }
|
||||
.ui-icon-folder-collapsed { background-position: 0 -96px; }
|
||||
.ui-icon-folder-open { background-position: -16px -96px; }
|
||||
.ui-icon-document { background-position: -32px -96px; }
|
||||
.ui-icon-document-b { background-position: -48px -96px; }
|
||||
.ui-icon-note { background-position: -64px -96px; }
|
||||
.ui-icon-mail-closed { background-position: -80px -96px; }
|
||||
.ui-icon-mail-open { background-position: -96px -96px; }
|
||||
.ui-icon-suitcase { background-position: -112px -96px; }
|
||||
.ui-icon-comment { background-position: -128px -96px; }
|
||||
.ui-icon-person { background-position: -144px -96px; }
|
||||
.ui-icon-print { background-position: -160px -96px; }
|
||||
.ui-icon-trash { background-position: -176px -96px; }
|
||||
.ui-icon-locked { background-position: -192px -96px; }
|
||||
.ui-icon-unlocked { background-position: -208px -96px; }
|
||||
.ui-icon-bookmark { background-position: -224px -96px; }
|
||||
.ui-icon-tag { background-position: -240px -96px; }
|
||||
.ui-icon-home { background-position: 0 -112px; }
|
||||
.ui-icon-flag { background-position: -16px -112px; }
|
||||
.ui-icon-calendar { background-position: -32px -112px; }
|
||||
.ui-icon-cart { background-position: -48px -112px; }
|
||||
.ui-icon-pencil { background-position: -64px -112px; }
|
||||
.ui-icon-clock { background-position: -80px -112px; }
|
||||
.ui-icon-disk { background-position: -96px -112px; }
|
||||
.ui-icon-calculator { background-position: -112px -112px; }
|
||||
.ui-icon-zoomin { background-position: -128px -112px; }
|
||||
.ui-icon-zoomout { background-position: -144px -112px; }
|
||||
.ui-icon-search { background-position: -160px -112px; }
|
||||
.ui-icon-wrench { background-position: -176px -112px; }
|
||||
.ui-icon-gear { background-position: -192px -112px; }
|
||||
.ui-icon-heart { background-position: -208px -112px; }
|
||||
.ui-icon-star { background-position: -224px -112px; }
|
||||
.ui-icon-link { background-position: -240px -112px; }
|
||||
.ui-icon-cancel { background-position: 0 -128px; }
|
||||
.ui-icon-plus { background-position: -16px -128px; }
|
||||
.ui-icon-plusthick { background-position: -32px -128px; }
|
||||
.ui-icon-minus { background-position: -48px -128px; }
|
||||
.ui-icon-minusthick { background-position: -64px -128px; }
|
||||
.ui-icon-close { background-position: -80px -128px; }
|
||||
.ui-icon-closethick { background-position: -96px -128px; }
|
||||
.ui-icon-key { background-position: -112px -128px; }
|
||||
.ui-icon-lightbulb { background-position: -128px -128px; }
|
||||
.ui-icon-scissors { background-position: -144px -128px; }
|
||||
.ui-icon-clipboard { background-position: -160px -128px; }
|
||||
.ui-icon-copy { background-position: -176px -128px; }
|
||||
.ui-icon-contact { background-position: -192px -128px; }
|
||||
.ui-icon-image { background-position: -208px -128px; }
|
||||
.ui-icon-video { background-position: -224px -128px; }
|
||||
.ui-icon-script { background-position: -240px -128px; }
|
||||
.ui-icon-alert { background-position: 0 -144px; }
|
||||
.ui-icon-info { background-position: -16px -144px; }
|
||||
.ui-icon-notice { background-position: -32px -144px; }
|
||||
.ui-icon-help { background-position: -48px -144px; }
|
||||
.ui-icon-check { background-position: -64px -144px; }
|
||||
.ui-icon-bullet { background-position: -80px -144px; }
|
||||
.ui-icon-radio-off { background-position: -96px -144px; }
|
||||
.ui-icon-radio-on { background-position: -112px -144px; }
|
||||
.ui-icon-pin-w { background-position: -128px -144px; }
|
||||
.ui-icon-pin-s { background-position: -144px -144px; }
|
||||
.ui-icon-play { background-position: 0 -160px; }
|
||||
.ui-icon-pause { background-position: -16px -160px; }
|
||||
.ui-icon-seek-next { background-position: -32px -160px; }
|
||||
.ui-icon-seek-prev { background-position: -48px -160px; }
|
||||
.ui-icon-seek-end { background-position: -64px -160px; }
|
||||
.ui-icon-seek-start { background-position: -80px -160px; }
|
||||
/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */
|
||||
.ui-icon-seek-first { background-position: -80px -160px; }
|
||||
.ui-icon-stop { background-position: -96px -160px; }
|
||||
.ui-icon-eject { background-position: -112px -160px; }
|
||||
.ui-icon-volume-off { background-position: -128px -160px; }
|
||||
.ui-icon-volume-on { background-position: -144px -160px; }
|
||||
.ui-icon-power { background-position: 0 -176px; }
|
||||
.ui-icon-signal-diag { background-position: -16px -176px; }
|
||||
.ui-icon-signal { background-position: -32px -176px; }
|
||||
.ui-icon-battery-0 { background-position: -48px -176px; }
|
||||
.ui-icon-battery-1 { background-position: -64px -176px; }
|
||||
.ui-icon-battery-2 { background-position: -80px -176px; }
|
||||
.ui-icon-battery-3 { background-position: -96px -176px; }
|
||||
.ui-icon-circle-plus { background-position: 0 -192px; }
|
||||
.ui-icon-circle-minus { background-position: -16px -192px; }
|
||||
.ui-icon-circle-close { background-position: -32px -192px; }
|
||||
.ui-icon-circle-triangle-e { background-position: -48px -192px; }
|
||||
.ui-icon-circle-triangle-s { background-position: -64px -192px; }
|
||||
.ui-icon-circle-triangle-w { background-position: -80px -192px; }
|
||||
.ui-icon-circle-triangle-n { background-position: -96px -192px; }
|
||||
.ui-icon-circle-arrow-e { background-position: -112px -192px; }
|
||||
.ui-icon-circle-arrow-s { background-position: -128px -192px; }
|
||||
.ui-icon-circle-arrow-w { background-position: -144px -192px; }
|
||||
.ui-icon-circle-arrow-n { background-position: -160px -192px; }
|
||||
.ui-icon-circle-zoomin { background-position: -176px -192px; }
|
||||
.ui-icon-circle-zoomout { background-position: -192px -192px; }
|
||||
.ui-icon-circle-check { background-position: -208px -192px; }
|
||||
.ui-icon-circlesmall-plus { background-position: 0 -208px; }
|
||||
.ui-icon-circlesmall-minus { background-position: -16px -208px; }
|
||||
.ui-icon-circlesmall-close { background-position: -32px -208px; }
|
||||
.ui-icon-squaresmall-plus { background-position: -48px -208px; }
|
||||
.ui-icon-squaresmall-minus { background-position: -64px -208px; }
|
||||
.ui-icon-squaresmall-close { background-position: -80px -208px; }
|
||||
.ui-icon-grip-dotted-vertical { background-position: 0 -224px; }
|
||||
.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; }
|
||||
.ui-icon-grip-solid-vertical { background-position: -32px -224px; }
|
||||
.ui-icon-grip-solid-horizontal { background-position: -48px -224px; }
|
||||
.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
|
||||
.ui-icon-grip-diagonal-se { background-position: -80px -224px; }
|
||||
|
||||
|
||||
/* Misc visuals
|
||||
----------------------------------*/
|
||||
|
||||
/* Corner radius */
|
||||
.ui-corner-all, .ui-corner-top, .ui-corner-left, .ui-corner-tl { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; -khtml-border-top-left-radius: 4px; border-top-left-radius: 4px; }
|
||||
.ui-corner-all, .ui-corner-top, .ui-corner-right, .ui-corner-tr { -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; -khtml-border-top-right-radius: 4px; border-top-right-radius: 4px; }
|
||||
.ui-corner-all, .ui-corner-bottom, .ui-corner-left, .ui-corner-bl { -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; -khtml-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; }
|
||||
.ui-corner-all, .ui-corner-bottom, .ui-corner-right, .ui-corner-br { -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; -khtml-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; }
|
||||
|
||||
/* Overlays */
|
||||
.ui-widget-overlay { background: #666666 url(images/ui-bg_diagonals-thick_20_666666_40x40.png) 50% 50% repeat; opacity: .50;filter:Alpha(Opacity=50); }
|
||||
.ui-widget-shadow { margin: -5px 0 0 -5px; padding: 5px; background: #000000 url(images/ui-bg_flat_10_000000_40x100.png) 50% 50% repeat-x; opacity: .20;filter:Alpha(Opacity=20); -moz-border-radius: 5px; -khtml-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; }/*
|
||||
* jQuery UI Datepicker 1.8.14
|
||||
*
|
||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
* http://jquery.org/license
|
||||
*
|
||||
* http://docs.jquery.com/UI/Datepicker#theming
|
||||
*/
|
||||
.ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; }
|
||||
.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; }
|
||||
.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; }
|
||||
.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; }
|
||||
.ui-datepicker .ui-datepicker-prev { left:2px; }
|
||||
.ui-datepicker .ui-datepicker-next { right:2px; }
|
||||
.ui-datepicker .ui-datepicker-prev-hover { left:1px; }
|
||||
.ui-datepicker .ui-datepicker-next-hover { right:1px; }
|
||||
.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
|
||||
.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
|
||||
.ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; }
|
||||
.ui-datepicker select.ui-datepicker-month-year {width: 100%;}
|
||||
.ui-datepicker select.ui-datepicker-month,
|
||||
.ui-datepicker select.ui-datepicker-year { width: 49%;}
|
||||
.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
|
||||
.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; }
|
||||
.ui-datepicker td { border: 0; padding: 1px; }
|
||||
.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; }
|
||||
.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; }
|
||||
.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; }
|
||||
.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; }
|
||||
|
||||
/* with multiple calendars */
|
||||
.ui-datepicker.ui-datepicker-multi { width:auto; }
|
||||
.ui-datepicker-multi .ui-datepicker-group { float:left; }
|
||||
.ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; }
|
||||
.ui-datepicker-multi-2 .ui-datepicker-group { width:50%; }
|
||||
.ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; }
|
||||
.ui-datepicker-multi-4 .ui-datepicker-group { width:25%; }
|
||||
.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; }
|
||||
.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; }
|
||||
.ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; }
|
||||
.ui-datepicker-row-break { clear:both; width:100%; font-size:0em; }
|
||||
|
||||
/* RTL support */
|
||||
.ui-datepicker-rtl { direction: rtl; }
|
||||
.ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; }
|
||||
.ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; }
|
||||
.ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; }
|
||||
.ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; }
|
||||
.ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; }
|
||||
.ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; }
|
||||
.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; }
|
||||
.ui-datepicker-rtl .ui-datepicker-group { float:right; }
|
||||
.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
|
||||
.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
|
||||
|
||||
/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */
|
||||
.ui-datepicker-cover {
|
||||
display: none; /*sorry for IE5*/
|
||||
display/**/: block; /*sorry for IE5*/
|
||||
position: absolute; /*must have*/
|
||||
z-index: -1; /*must have*/
|
||||
filter: mask(); /*must have*/
|
||||
top: -4px; /*must have*/
|
||||
left: -4px; /*must have*/
|
||||
width: 200px; /*must have*/
|
||||
height: 200px; /*must have*/
|
||||
}
|
||||
|
Before Width: | Height: | Size: 260 B |
|
Before Width: | Height: | Size: 251 B |
|
Before Width: | Height: | Size: 178 B |
|
Before Width: | Height: | Size: 104 B |
|
Before Width: | Height: | Size: 125 B |
|
Before Width: | Height: | Size: 105 B |