/*
Plugin Name: Gravity Forms
Plugin URI: http://www.gravityforms.com
Description: Easily create web forms and manage form entries within the WordPress admin.
Version: 1.5.2.1
Author: rocketgenius
Author URI: http://www.rocketgenius.com
------------------------------------------------------------------------
Copyright 2009-2010 rocketgenius llc.
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
*/
//------------------------------------------------------------------------------------------------------------------
//---------- Gravity Forms License Key -----------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------
//If you hardcode a Gravity Forms License Key here, it will automatically populate on activation.
$gf_license_key = "";
//-- OR ---//
//You can also add the Gravity Forms license key to your wp-config.php file to automatically populate on activation
//Add the code in the comment below to your wp-config.php to do so:
//define('GF_LICENSE_KEY','YOUR_KEY_GOES_HERE');
//------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------
//---------- reCAPTCHA Keys -----------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------
//If you hardcode your reCAPTCHA Keys here, it will automatically populate on activation.
$gf_recaptcha_private_key = "";
$gf_recaptcha_public_key = "";
//-- OR ---//
//You can also add the reCAPTCHA keys to your wp-config.php file to automatically populate on activation
//Add the two lines of code in the comment below to your wp-config.php to do so:
//define('GF_RECAPTCHA_PRIVATE_KEY','YOUR_PRIVATE_KEY_GOES_HERE');
//define('GF_RECAPTCHA_PUBLIC_KEY','YOUR_PUBLIC_KEY_GOES_HERE');
//------------------------------------------------------------------------------------------------------------------
if(!defined("RG_CURRENT_PAGE"))
define("RG_CURRENT_PAGE", basename($_SERVER['PHP_SELF']));
if(!defined("IS_ADMIN"))
define("IS_ADMIN", is_admin());
define("RG_CURRENT_VIEW", RGForms::get("view"));
define("GF_SUPPORTED_WP_VERSION", version_compare(get_bloginfo("version"), '2.8.0', '>='));
if(!defined("GRAVITY_MANAGER_URL"))
define("GRAVITY_MANAGER_URL", "http://www.gravityhelp.com/wp-content/plugins/gravitymanager");
require_once(WP_PLUGIN_DIR . "/" . basename(dirname(__FILE__)) . "/common.php");
require_once(WP_PLUGIN_DIR . "/" . basename(dirname(__FILE__)) . "/forms_model.php");
require_once(WP_PLUGIN_DIR . "/" . basename(dirname(__FILE__)) . "/widget.php");
add_action('init', array('RGForms', 'init'));
add_action('wp', array('RGForms', 'maybe_process_form'), 9);
class RGForms{
public static function maybe_process_form(){
$form_id = isset($_POST["gform_submit"]) ? $_POST["gform_submit"] : 0;
if($form_id){
require_once(GFCommon::get_base_path() . "/form_display.php");
GFFormDisplay::process_form($form_id);
}
}
//Plugin starting point. Will load appropriate files
public static function init(){
load_plugin_textdomain( 'gravityforms', FALSE, '/gravityforms/languages' );
if(IS_ADMIN){
global $current_user;
//Members plugin integration. Adding Gravity Forms roles to the checkbox list
if ( function_exists( 'members_get_capabilities' ) ){
add_filter('members_get_capabilities', array("RGForms", "members_get_capabilities"));
//Removing default GF capability when integrating with Members
if(current_user_can("gform_full_access"))
$current_user->remove_cap("gform_full_access");
//If and administrator does not have any Gravity Form permission, add all of them. (will happen the first time Gravity Forms gets installed)
self::initialize_permissions();
}
else
{
$gform_full_access = current_user_can("administrator") ? "gform_full_access" : "";
$gform_full_access = apply_filters("gform_cap_full_access", $gform_full_access);
if(!empty($gform_full_access))
$current_user->add_cap($gform_full_access);
}
//Loading Gravity Forms if user has access to any functionality
if(GFCommon::current_user_can_any(GFCommon::all_caps()))
{
require_once(GFCommon::get_base_path() . "/export.php");
GFExport::maybe_export();
//runs the setup when version changes
self::setup();
//creates the "Forms" left menu
add_action('admin_menu', array('RGForms', 'create_menu'));
if(GF_SUPPORTED_WP_VERSION){
add_action('admin_footer', array('RGForms', 'check_upload_folder'));
add_action('wp_dashboard_setup', array('RGForms', 'dashboard_setup'));
//Adding "embed form" button
add_action('media_buttons_context', array('RGForms', 'add_form_button'));
//Plugin update actions
add_filter("transient_update_plugins", array('RGForms', 'check_update'));
add_filter("site_transient_update_plugins", array('RGForms', 'check_update'));
if(in_array(RG_CURRENT_PAGE, array('post.php', 'page.php', 'page-new.php', 'post-new.php'))){
add_action('admin_footer', array('RGForms', 'add_mce_popup'));
}
else if(self::is_gravity_page()){
require_once(GFCommon::get_base_path() . "/tooltips.php");
add_action("admin_print_scripts", array('RGForms', 'print_scripts'));
}
else if(in_array(RG_CURRENT_PAGE, array("admin.php", "admin-ajax.php"))){
add_action('wp_ajax_rg_save_form', array('RGForms', 'save_form'));
add_action('wp_ajax_rg_change_input_type', array('RGForms', 'change_input_type'));
add_action('wp_ajax_rg_add_field', array('RGForms', 'add_field'));
add_action('wp_ajax_rg_delete_field', array('RGForms', 'delete_field'));
add_action('wp_ajax_rg_delete_file', array('RGForms', 'delete_file'));
add_action('wp_ajax_rg_select_export_form', array('RGForms', 'select_export_form'));
add_action('wp_ajax_rg_start_export', array('RGForms', 'start_export'));
add_action('wp_ajax_gf_upgrade_license', array('RGForms', 'upgrade_license'));
//entry list ajax operations
add_action('wp_ajax_rg_update_lead_property', array('RGForms', 'update_lead_property'));
//form list ajax operations
add_action('wp_ajax_rg_update_form_active', array('RGForms', 'update_form_active'));
//dynamic captcha image
add_action('wp_ajax_rg_captcha_image', array('RGForms', 'captcha_image'));
//dashboard message "dismiss upgrade" link
add_action("wp_ajax_rg_dismiss_upgrade", array('RGForms', 'dashboard_dismiss_upgrade'));
}
add_filter("plugins_api", array("RGForms", "get_addon_info"), 10, 3);
add_action('after_plugin_row_gravityforms/gravityforms.php', array('RGForms', 'plugin_row') );
add_action('install_plugins_pre_plugin-information', array('RGForms', 'display_changelog'));
add_filter('plugin_action_links', array('RGForms', 'plugin_settings_link'),10,2);
}
}
}
else{
add_action('wp_enqueue_scripts', array('RGForms', 'enqueue_scripts'));
add_action('wp', array('RGForms', 'ajax_parse_request'), 10);
}
add_shortcode('gravityform', array('RGForms', 'parse_shortcode'));
}
public static function check_update($update_plugins_option){
if(!class_exists("GFCommon"))
require_once("common.php");
return GFCommon::check_update($update_plugins_option, true);
}
//Setup permissions if Members plugin is installed, or give current user full GF permission if not.
public static function initialize_permissions(){
global $current_user;
$is_gravity_forms_installation = get_option("rg_form_version") != GFCommon::$version;
$is_members_installation = get_option("rg_members_installed");
$is_admin_with_no_permissions = current_user_can("administrator") && !GFCommon::current_user_can_any(GFCommon::all_caps());
//if this is a new gf install or members install and the administrator doesn't have any Gravity Forms permission, add all of them.
if( ($is_gravity_forms_installation || $is_members_installation) && $is_admin_with_no_permissions){
$role = get_role("administrator");
foreach(GFCommon::all_caps() as $cap){
$role->add_cap($cap);
}
update_option("rg_members_installed", true);
}
}
//Creates or updates database tables. Will only run when version changes
public static function setup(){
global $wpdb;
$version = GFCommon::$version;
if(get_option("rg_form_version") != $version){
require_once(ABSPATH . '/wp-admin/includes/upgrade.php');
if ( ! empty($wpdb->charset) )
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
if ( ! empty($wpdb->collate) )
$charset_collate .= " COLLATE $wpdb->collate";
//------ FORM -----------------------------------------------
$form_table_name = RGFormsModel::get_form_table_name();
$sql = "CREATE TABLE " . $form_table_name . " (
id mediumint(8) unsigned not null auto_increment,
title varchar(150) not null,
date_created datetime not null,
is_active tinyint(1) not null default 1,
PRIMARY KEY (id)
) $charset_collate;";
dbDelta($sql);
//------ META -----------------------------------------------
$meta_table_name = RGFormsModel::get_meta_table_name();
$sql = "CREATE TABLE " . $meta_table_name . " (
form_id mediumint(8) unsigned not null,
display_meta longtext,
entries_grid_meta longtext,
KEY form_id (form_id)
) $charset_collate;";
dbDelta($sql);
//------ FORM VIEW -----------------------------------------------
$form_view_table_name = RGFormsModel::get_form_view_table_name();
$sql = "CREATE TABLE " . $form_view_table_name . " (
id bigint(20) unsigned not null auto_increment,
form_id mediumint(8) unsigned not null,
date_created datetime not null,
ip char(15),
count mediumint(8) unsigned not null default 1,
PRIMARY KEY (id),
KEY form_id (form_id)
) $charset_collate;";
dbDelta($sql);
//------ LEAD -----------------------------------------------
$lead_table_name = RGFormsModel::get_lead_table_name();
$sql = "CREATE TABLE " . $lead_table_name . " (
id int(10) unsigned not null auto_increment,
form_id mediumint(8) unsigned not null,
post_id bigint(20) unsigned,
date_created datetime not null,
is_starred tinyint(1) not null default 0,
is_read tinyint(1) not null default 0,
ip varchar(39) not null,
source_url varchar(200) not null default '',
user_agent varchar(250) not null default '',
currency varchar(5),
payment_status varchar(15),
payment_date datetime,
payment_amount decimal(19,2),
transaction_id varchar(50),
is_fulfilled tinyint(1),
created_by bigint(20) unsigned,
transaction_type tinyint(1),
PRIMARY KEY (id),
KEY form_id (form_id)
) $charset_collate;";
dbDelta($sql);
//------ LEAD NOTES ------------------------------------------
$lead_notes_table_name = RGFormsModel::get_lead_notes_table_name();
$sql = "CREATE TABLE " . $lead_notes_table_name . " (
id int(10) unsigned not null auto_increment,
lead_id int(10) unsigned not null,
user_name varchar(250),
user_id bigint(20),
date_created datetime not null,
value longtext,
PRIMARY KEY (id),
KEY lead_id (lead_id),
KEY lead_user_key (lead_id,user_id)
) $charset_collate;";
dbDelta($sql);
//------ LEAD DETAIL -----------------------------------------
$lead_detail_table_name = RGFormsModel::get_lead_details_table_name();
$sql = "CREATE TABLE " . $lead_detail_table_name . " (
id bigint(20) unsigned not null auto_increment,
lead_id int(10) unsigned not null,
form_id mediumint(8) unsigned not null,
field_number float not null,
value varchar(". GFORMS_MAX_FIELD_LENGTH ."),
PRIMARY KEY (id),
KEY form_id (form_id),
KEY lead_id (lead_id)
) $charset_collate;";
dbDelta($sql);
//------ LEAD DETAIL LONG -----------------------------------
$lead_detail_long_table_name = RGFormsModel::get_lead_details_long_table_name();
$sql = "CREATE TABLE " . $lead_detail_long_table_name . " (
lead_detail_id bigint(20) unsigned not null,
value longtext,
KEY lead_detail_key (lead_detail_id)
) $charset_collate;";
dbDelta($sql);
//fix checkbox value. needed for version 1.0 and below but won't hurt for higher versions
self::fix_checkbox_value();
//auto-setting license key based on value configured via the GF_LICENSE_KEY constant or the gf_license_key variable
global $gf_license_key;
$license_key = defined("GF_LICENSE_KEY") && empty($gf_license_key) ? GF_LICENSE_KEY : $gf_license_key;
if(!empty($license_key))
update_option("rg_gforms_key", md5($license_key));
//auto-setting recaptcha keys based on value configured via the constant or global variable
global $gf_recaptcha_public_key, $gf_recaptcha_private_key;
$private_key = defined("GF_RECAPTCHA_PRIVATE_KEY") && empty($gf_recaptcha_private_key) ? GF_RECAPTCHA_PRIVATE_KEY : $gf_recaptcha_private_key;
if(!empty($private_key))
update_option("rg_gforms_captcha_private_key", $private_key);
$public_key = defined("GF_RECAPTCHA_PUBLIC_KEY") && empty($gf_recaptcha_public_key) ? GF_RECAPTCHA_PUBLIC_KEY : $gf_recaptcha_public_key;
if(!empty($public_key))
update_option("rg_gforms_captcha_public_key", $public_key);
//Auto-importing forms based on GF_IMPORT_FILE AND GF_THEME_IMPORT_FILE
if(defined("GF_IMPORT_FILE") && !get_option("gf_imported_file")){
GFExport::import_file(GF_IMPORT_FILE);
update_option("gf_imported_file", true);
}
update_option("rg_form_version", $version);
}
//Import theme specific forms if configured. Will only import forms once per theme.
if(defined("GF_THEME_IMPORT_FILE")){
$themes = get_option("gf_imported_theme_file");
if(!is_array($themes))
$themes = array();
//if current theme has already imported it's forms, don't import again
$theme = get_template();
if(!isset($themes[$theme])){
//importing forms
GFExport::import_file(get_stylesheet_directory() . "/" . GF_THEME_IMPORT_FILE);
//adding current theme to the list of imported themes. So that forms are not imported again for it.
$themes[$theme] = true;
update_option("gf_imported_theme_file", $themes);
}
}
}
//Changes checkbox entry values from "!" to the current choice text. Neededed when upgrading users from 1.0
private static function fix_checkbox_value(){
global $wpdb;
$table_name = RGFormsModel::get_lead_details_table_name();
$sql = "select * from $table_name where value= '!'";
$results = $wpdb->get_results($sql);
foreach($results as $result){
$form = RGFormsModel::get_form_meta($result->form_id);
$field = RGFormsModel::get_field($form, $result->field_number);
if($field["type"] == "checkbox"){
$input = GFCommon::get_input($field, $result->field_number);
$wpdb->update($table_name, array("value" => $input["label"]), array("id" => $result->id));
}
}
}
//Target of Member plugin filter. Provides the plugin with Gravity Forms lists of capabilities
public static function members_get_capabilities( $caps ) {
return array_merge($caps, GFCommon::all_caps());
}
//Tests if the upload folder is writable and displays an error message if not
public static function check_upload_folder(){
//check if upload folder is writable
$folder = RGFormsModel::get_upload_root();
if(empty($folder))
echo "
Upload folder is not writable. Export and file upload features will not be functional.
";
}
//Prints common admin scripts
public static function print_scripts(){
wp_enqueue_script("sack");
wp_print_scripts();
}
//Returns true if the current page is one of Gravity Forms pages. Returns false if not
private static function is_gravity_page(){
$current_page = trim(strtolower(self::get("page")));
$gf_pages = array("gf_edit_forms","gf_new_form","gf_entries","gf_settings","gf_export","gf_help");
return in_array($current_page, $gf_pages);
}
//Creates "Forms" left nav
public static function create_menu(){
$has_full_access = current_user_can("gform_full_access");
$min_cap = GFCommon::current_user_can_which(GFCommon::all_caps());
if(empty($min_cap))
$min_cap = "gform_full_access";
$addon_menus = array();
$addon_menus = apply_filters("gform_addon_navigation", $addon_menus);
$parent_menu = self::get_parent_menu($addon_menus);
// Add a top-level left nav
$update_icon = GFCommon::has_update() ? "1" : "";
add_object_page(__('Forms', "gravityforms"), __("Forms", "gravityforms") . $update_icon , $has_full_access ? "gform_full_access" : $min_cap, $parent_menu["name"] , $parent_menu["callback"], GFCommon::get_base_url() . '/images/gravity-admin-icon.png');
// Adding submenu pages
add_submenu_page($parent_menu["name"], __("Edit Forms", "gravityforms"), __("Edit Forms", "gravityforms"), $has_full_access ? "gform_full_access" : "gravityforms_edit_forms", "gf_edit_forms", array("RGForms", "forms"));
add_submenu_page($parent_menu["name"], __("New Form", "gravityforms"), __("New Form", "gravityforms"), $has_full_access ? "gform_full_access" : "gravityforms_create_form", "gf_new_form", array("RGForms", "new_form"));
add_submenu_page($parent_menu["name"], __("Entries", "gravityforms"), __("Entries", "gravityforms"), $has_full_access ? "gform_full_access" : "gravityforms_view_entries", "gf_entries", array("RGForms", "all_leads_page"));
if(is_array($addon_menus)){
foreach($addon_menus as $addon_menu)
add_submenu_page($parent_menu["name"], $addon_menu["label"], $addon_menu["label"], $has_full_access ? "gform_full_access" : $addon_menu["permission"], $addon_menu["name"], $addon_menu["callback"]);
}
add_submenu_page($parent_menu["name"], __("Settings", "gravityforms"), __("Settings", "gravityforms"), $has_full_access ? "gform_full_access" : "gravityforms_view_settings", "gf_settings", array("RGForms", "settings_page"));
add_submenu_page($parent_menu["name"], __("Import/Export", "gravityforms"), __("Import/Export", "gravityforms"), $has_full_access ? "gform_full_access" : "gravityforms_export_entries", "gf_export", array("RGForms", "export_page"));
//if(!function_exists("is_multisite") || !is_multisite() || is_super_admin())
if(current_user_can("install_plugins")){
add_submenu_page($parent_menu["name"], __("Updates", "gravityforms"), __("Updates", "gravityforms"), $has_full_access ? "gform_full_access" : "gravityforms_view_updates", "gf_update", array("RGForms", "update_page"));
add_submenu_page($parent_menu["name"], __("Add-Ons", "gravityforms"), __("Add-Ons", "gravityforms"), $has_full_access ? "gform_full_access" : "gravityforms_view_addons", "gf_addons", array("RGForms", "addons_page"));
}
add_submenu_page($parent_menu["name"], __("Help", "gravityforms"), __("Help", "gravityforms"), $has_full_access ? "gform_full_access" : $min_cap, "gf_help", array("RGForms", "help_page"));
}
//Returns the parent menu item. It needs to be the same as the first sub-menu (otherwise WP will duplicate the main menu as a sub-menu)
public static function get_parent_menu($addon_menus){
if(GFCommon::current_user_can_any("gravityforms_edit_forms"))
$parent = array("name" => "gf_edit_forms", "callback" => array("RGForms", "forms"));
else if(GFCommon::current_user_can_any("gravityforms_create_form"))
$parent = array("name" => "gf_new_form", "callback" => array("RGForms", "new_form"));
else if(GFCommon::current_user_can_any("gravityforms_view_entries"))
$parent = array("name" => "gf_entries", "callback" => array("RGForms", "all_leads_page"));
else if(is_array($addon_menus) && sizeof($addon_menus) > 0){
foreach($addon_menus as $addon_menu)
if(GFCommon::current_user_can_any($addon_menu["permission"]))
{
$parent = array("name" => $addon_menu["name"], "callback" => $addon_menu["callback"]);
break;
}
}
else if(GFCommon::current_user_can_any("gravityforms_view_settings"))
$parent = array("name" => "gf_settings", "callback" => array("RGForms", "settings_page"));
else if(GFCommon::current_user_can_any("gravityforms_export_entries"))
$parent = array("name" => "gf_export", "callback" => array("RGForms", "export_page"));
else if(GFCommon::current_user_can_any("gravityforms_view_updates"))
$parent = array("name" => "gf_update", "callback" => array("RGForms", "update_page"));
else if(GFCommon::current_user_can_any("gravityforms_view_addons"))
$parent = array("name" => "gf_addons", "callback" => array("RGForms", "addons_page"));
else if(GFCommon::current_user_can_any(GFCommon::all_caps()))
$parent = array("name" => "gf_help", "callback" => array("RGForms", "help_page"));
return $parent;
}
//Parses the [gravityform shortcode and returns the front end form UI
public static function parse_shortcode($attributes){
extract(shortcode_atts(array(
'title' => true,
'description' => true,
'id' => 0,
'field_values' => "",
'ajax' => false
), $attributes));
$title = strtolower($title) == "false" ? false : true;
$description = strtolower($description) == "false" ? false : true;
$field_values = htmlspecialchars_decode($field_values);
$ajax = strtolower($ajax) == "true" ? true : false;
parse_str($field_values, $field_value_array); //parsing query string like string for field values and placing them into an associative array
$field_value_array = stripslashes_deep($field_value_array);
return self::get_form($id, $title, $description, false, $field_value_array, $ajax);
}
//-------------------------------------------------
//----------- AJAX --------------------------------
public function ajax_parse_request($wp) {
if (isset($_POST["gform_ajax"])) {
parse_str($_POST["gform_ajax"]);
require_once(GFCommon::get_base_path() . "/form_display.php");
$result = GFFormDisplay::get_form($form_id, $title, $description, false, $_POST["gform_field_values"], true);
die("$result");
}
}
//------------------------------------------------------
//------------- PAGE/POST EDIT PAGE ---------------------
//Action target that adds the "Insert Form" button to the post/page edit screen
public static function add_form_button($context){
$image_btn = GFCommon::get_base_url() . "/images/form-button.png";
$out = '
';
return $context . $out;
}
//Action target that displays the popup to insert a form to a post/page
function add_mce_popup(){
?>
}
//------------------------------------------------------
//------------- PLUGINS PAGE ---------------------------
//------------------------------------------------------
public static function plugin_settings_link( $links, $file ) {
if ( $file != plugin_basename( __FILE__ ))
return $links;
array_unshift($links, '' . __( 'Settings', 'gravityforms' ) . '');
return $links;
}
//Displays message on Plugin's page
public static function plugin_row($plugin_name){
$key = GFCommon::get_key();
$version_info = GFCommon::get_version_info();
if(!$version_info["is_valid_key"]){
$plugin_name = "gravityforms/gravityforms.php";
$new_version = version_compare(GFCommon::$version, $version_info["version"], '<') ? __('There is a new version of Gravity Forms available.', 'gravityforms') .' '. sprintf(__('View version %s Details', 'gravityforms'), $version_info["version"]) . '. ' : '';
echo '' . $new_version . __(' Register your copy of Gravity Forms to receive access to automatic upgrades and support. Need a license key? Purchase one now.', 'gravityforms') . ' | ';
}
}
//Displays current version details on Plugin's page
public static function display_changelog(){
if($_REQUEST["plugin"] != "gravityforms")
return;
$page_text = self::get_changelog();
echo $page_text;
exit;
}
public static function get_changelog(){
$key = GFCommon::get_key();
$body = "key=$key";
$options = array('method' => 'POST', 'timeout' => 3, 'body' => $body);
$options['headers'] = array(
'Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'),
'Content-Length' => strlen($body),
'User-Agent' => 'WordPress/' . get_bloginfo("version"),
'Referer' => get_bloginfo("url")
);
$raw_response = wp_remote_request(GRAVITY_MANAGER_URL . "/changelog.php?" . GFCommon::get_remote_request_params(), $options);
if ( is_wp_error( $raw_response ) || 200 != $raw_response['response']['code']){
$page_text = __("Oops!! Something went wrong.
Please try again or contact us.", 'gravityforms');
}
else{
$page_text = $raw_response['body'];
if(substr($page_text, 0, 10) != "")
$page_text = "";
}
return stripslashes($page_text);
}
//------------------------------------------------------
//-------------- DASHBOARD PAGE -------------------------
//Registers the dashboard widget
public static function dashboard_setup(){
wp_add_dashboard_widget('rg_forms_dashboard', 'Gravity Forms', array('RGForms', 'dashboard'));
}
//Displays the dashboard UI
public static function dashboard(){
$forms = RGFormsModel::get_form_summary();
if(sizeof($forms) > 0){
?>
| Form Name
| Unread Entries
| Last Entry
|
foreach($forms as $form){
$date_display = GFCommon::format_date($form["last_lead_date"]);
?>
|
|
}
?>
View All Forms
}
else{
?>
}
if(GFCommon::current_user_can_any("gravityforms_view_updates") && (!function_exists("is_multisite") || !is_multisite() || is_super_admin())){
//displaying update message if there is an update and user has permission
self::dashboard_update_message();
}
}
public static function dashboard_update_message(){
$version_info = GFCommon::get_version_info();
//don't display a message if use has dismissed the message for this version
$ary_dismissed = get_option("gf_dismissed_upgrades");
$is_dismissed = !empty($ary_dismissed) && in_array($version_info["version"], $ary_dismissed);
if($is_dismissed)
return;
if(version_compare(GFCommon::$version, $version_info["version"], '<')) {
$auto_upgrade = "";
/*if($version_info["is_valid_key"]){
$plugin_file = "gravityforms/gravityforms.php";
$upgrade_url = wp_nonce_url('update.php?action=upgrade-plugin&plugin=' . urlencode($plugin_file), 'upgrade-plugin_' . $plugin_file);
$auto_upgrade = sprintf(__(" or %sUpgrade Automatically%s", "gravityforms"), "", "");
}*/
$message = sprintf(__("There is an update available for Gravity Forms. %sView Details%s %s", "gravityforms"), "", "", $auto_upgrade);
?>
}
}
public static function dashboard_dismiss_upgrade(){
$ary = get_option("gf_dismissed_upgrades");
if(!is_array($ary))
$ary = array();
$ary[] = $_POST["version"];
update_option("gf_dismissed_upgrades", $ary);
}
//------------------------------------------------------
//--------------- ALL OTHER PAGES ---------------------
public static function get_form($form_id, $display_title=true, $display_description=true, $force_display=false, $field_values=null, $ajax=false){
require_once(GFCommon::get_base_path() . "/form_display.php");
return GFFormDisplay::get_form($form_id, $display_title, $display_description, $force_display, $field_values, $ajax);
}
public static function new_form(){
self::forms_page(0);
}
public static function enqueue_scripts(){
require_once(GFCommon::get_base_path() . "/form_display.php");
GFFormDisplay::enqueue_scripts();
}
public static function print_form_scripts($form, $ajax){
require_once(GFCommon::get_base_path() . "/form_display.php");
GFFormDisplay::print_form_scripts($form, $ajax);
}
public static function forms_page($form_id){
require_once(GFCommon::get_base_path() . "/form_detail.php");
GFFormDetail::forms_page($form_id);
}
public static function settings_page(){
require_once(GFCommon::get_base_path() . "/settings.php");
GFSettings::settings_page();
}
public static function add_settings_page($name, $handle, $icon_path=""){
require_once(GFCommon::get_base_path() . "/settings.php");
GFSettings::add_settings_page($name, $handle, $icon_path);
}
public static function help_page(){
require_once(GFCommon::get_base_path() . "/help.php");
GFHelp::help_page();
}
public static function export_page(){
require_once(GFCommon::get_base_path() . "/export.php");
GFExport::export_page();
}
public static function update_page(){
require_once(GFCommon::get_base_path() . "/update.php");
GFUpdate::update_page();
}
public static function addons_page(){
wp_print_scripts("thickbox");
wp_print_styles(array("thickbox"));
$plugins = get_plugins();
$installed_plugins = array();
foreach($plugins as $key => $plugin){
$is_active = is_plugin_active($key);
$installed_plugin = array("plugin" => $key, "name" => $plugin["Name"], "is_active"=>$is_active);
$installed_plugin["activation_url"] = $is_active ? "" : wp_nonce_url("plugins.php?action=activate&plugin={$key}", "activate-plugin_{$key}");
$installed_plugin["deactivation_url"] = !$is_active ? "" : wp_nonce_url("plugins.php?action=deactivate&plugin={$key}", "deactivate-plugin_{$key}");
$installed_plugins[] = $installed_plugin;
}
$nonces = self::get_addon_nonces();
$body = array("plugins" => urlencode(serialize($installed_plugins)), "nonces" => urlencode(serialize($nonces)), "key" => GFCommon::get_key());
$options = array('body' => $body, 'headers' => array('Referer' => get_bloginfo("url")));
$request_url = GRAVITY_MANAGER_URL . "/api.php?op=plugin_browser&{$_SERVER["QUERY_STRING"]}";
$raw_response = wp_remote_post($request_url, $options);
if ( is_wp_error( $raw_response ) || $raw_response['response']['code'] != 200){
echo "" . __("Add-On brower is currently unavailable. Please try again later.", "gravityforms") . "
";
}
else{
echo GFCommon::get_remote_message();
echo $raw_response["body"];
}
}
public static function get_addon_info($api, $action, $args){
if($action == "plugin_information" && empty($api) && !rgempty("rg", $_GET)){
$request_url = GRAVITY_MANAGER_URL . "/api.php?op=get_plugin&slug={$args->slug}";
$raw_response = wp_remote_post($request_url);
if ( is_wp_error( $raw_response ) || $raw_response['response']['code'] != 200)
return false;
$plugin = unserialize($raw_response["body"]);
$api = new stdClass();
$api->name = $plugin["title"];
$api->version = $plugin["version"];
$api->download_link = $plugin["download_url"];
}
return $api;
}
public static function get_addon_nonces(){
$request_url = GRAVITY_MANAGER_URL . "/api.php?op=get_plugins";
$raw_response = wp_remote_get($request_url);
if ( is_wp_error( $raw_response ) || $raw_response['response']['code'] != 200)
return false;
$addons = unserialize($raw_response["body"]);
$nonces = array();
foreach($addons as $addon){
$nonces[$addon["key"]] = wp_create_nonce("install-plugin_{$addon["key"]}");
}
return $nonces;
}
public static function install_action_links($links, $plugin){
//if($theme != "alien")
// return $links;
//unset($links["activate"]);
unset($links["preview"]);
return $links;
}
public static function start_export(){
require_once(GFCommon::get_base_path() . "/export.php");
GFExport::start_export();
}
public static function all_leads_page(){
//displaying lead detail page if lead id is in the query string
$lead_id = RGForms::get("lid");
if(!empty($lead_id))
{
require_once(GFCommon::get_base_path() . "/entry_detail.php");
GFEntryDetail::lead_detail_page();
}
else{
require_once(GFCommon::get_base_path() . "/entry_list.php");
GFEntryList::all_leads_page();
}
}
public static function form_list_page(){
require_once(GFCommon::get_base_path() . "/form_list.php");
GFFormList::form_list_page();
}
public static function forms(){
if(!GFCommon::ensure_wp_version())
return;
$id = RGForms::get("id");
$view = RGForms::get("view");
if($view == "entries"){
require_once(GFCommon::get_base_path() . "/entry_list.php");
GFEntryList::leads_page($id);
}
else if($view == "entry"){
require_once(GFCommon::get_base_path() . "/entry_detail.php");
GFEntryDetail::lead_detail_page();
}
else if($view == "notification"){
require_once(GFCommon::get_base_path() . "/notification.php");
GFNotification::notification_page($id);
}
else if(is_numeric($id)){
self::forms_page($id);
}
else{
self::form_list_page();
}
}
public static function get($name, $array=null){
if(!$array)
$array = $_GET;
if(isset($array[$name]))
return $array[$name];
return "";
}
public static function post($name){
if(isset($_POST[$name]))
return $_POST[$name];
return "";
}
//-------------------------------------------------
//----------- AJAX CALLS --------------------------
//captcha image
public static function captcha_image(){
$field = array("simpleCaptchaSize" => $_GET["size"], "simpleCaptchaFontColor"=> $_GET["fg"], "simpleCaptchaBackgroundColor"=>$_GET["bg"]);
if($_GET["type"] == "math")
$captcha = GFCommon::get_math_captcha($field, $_GET["pos"]);
else
$captcha = GFCommon::get_captcha();
@ini_set('memory_limit', '256M');
$image = imagecreatefrompng($captcha["path"]);
include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
wp_stream_image($image, "image/png", 0);
imagedestroy($image);
die();
}
//entry list
public static function update_form_active(){
check_ajax_referer('rg_update_form_active','rg_update_form_active');
RGFormsModel::update_form_active($_POST["form_id"], $_POST["is_active"]);
}
public static function update_lead_property(){
check_ajax_referer('rg_update_lead_property','rg_update_lead_property');
RGFormsModel::update_lead_property($_POST["lead_id"], $_POST["name"], $_POST["value"]);
}
//settings
public static function upgrade_license(){
require_once(GFCommon::get_base_path() . "/settings.php");
GFSettings::upgrade_license();
}
//form detail
public static function save_form(){
require_once(GFCommon::get_base_path() . "/form_detail.php");
GFFormDetail::save_form();
}
public static function add_field(){
require_once(GFCommon::get_base_path() . "/form_detail.php");
GFFormDetail::add_field();
}
public static function delete_field(){
require_once(GFCommon::get_base_path() . "/form_detail.php");
GFFormDetail::delete_field();
}
public static function change_input_type(){
require_once(GFCommon::get_base_path() . "/form_detail.php");
GFFormDetail::change_input_type();
}
//entry detail
public static function delete_file(){
check_ajax_referer("rg_delete_file", "rg_delete_file");
$lead_id = intval($_POST["lead_id"]);
$field_id = intval($_POST["field_id"]);
RGFormsModel::delete_file($lead_id, $field_id);
die("EndDeleteFile($field_id);");
}
//export
public static function select_export_form(){
check_ajax_referer("rg_select_export_form", "rg_select_export_form");
$form_id = intval($_POST["form_id"]);
$form = RGFormsModel::get_form_meta($form_id);
$fields = array();
//Adding default fields
array_push($form["fields"],array("id" => "id" , "label" => __("Entry Id", "gravityforms")));
array_push($form["fields"],array("id" => "date_created" , "label" => __("Entry Date", "gravityforms")));
array_push($form["fields"],array("id" => "ip" , "label" => __("User IP", "gravityforms")));
array_push($form["fields"],array("id" => "source_url" , "label" => __("Source Url", "gravityforms")));
array_push($form["fields"],array("id" => "payment_status" , "label" => __("Payment Status", "gravityforms")));
array_push($form["fields"],array("id" => "payment_date" , "label" => __("Payment Date", "gravityforms")));
array_push($form["fields"],array("id" => "transaction_id" , "label" => __("Transaction Id", "gravityforms")));
if(is_array($form["fields"])){
foreach($form["fields"] as $field){
if(is_array(rgar($field,"inputs"))){
foreach($field["inputs"] as $input)
$fields[] = array($input["id"], GFCommon::get_label($field, $input["id"]));
}
else if(!rgar($field,"displayOnly")){
$fields[] = array($field["id"], GFCommon::get_label($field));
}
}
}
$field_json = GFCommon::json_encode($fields);
die("EndSelectExportForm($field_json);");
}
public static function top_toolbar(){
?>
}
private static function toolbar_class($item){
switch($item){
case "editor":
if(in_array(rgget("page"), array("gf_edit_forms", "gf_new_form")) && rgempty("view", $_GET))
return "class='gf_toolbar_active'";
break;
case "notifications" :
if(rgget("page") == "gf_new_form")
return "class='gf_toolbar_disabled'";
else if(rgget("page") == "gf_edit_forms" && rgget("view") == "notification")
return "class='gf_toolbar_active'";
break;
case "entries" :
if(rgget("page") == "gf_new_form")
return "class='gf_toolbar_disabled'";
else if(rgget("page") == "gf_entries")
return "class='gf_toolbar_active'";
break;
case "preview" :
if(rgget("page") == "gf_new_form")
return "class='gf_toolbar_disabled'";
break;
}
return "";
}
}
//Main function call. Should be used to insert a Gravity Form from code.
function gravity_form($id, $display_title=true, $display_description=true, $display_inactive=false, $field_values=null, $ajax=false){
echo RGForms::get_form($id, $display_title, $display_description, $display_inactive, $field_values, $ajax);
}
function gravity_form_enqueue_scripts($form_id, $is_ajax=false){
if(!is_admin()){
require_once(GFCommon::get_base_path() . "/form_display.php");
$form = RGFormsModel::get_form_meta($form_id);
GFFormDisplay::enqueue_form_scripts($form, $is_ajax);
}
}
if(!function_exists("rgget")){
function rgget($name, $array=null){
if(!isset($array))
$array = $_GET;
if(isset($array[$name]))
return $array[$name];
return "";
}
}
if(!function_exists("rgpost")){
function rgpost($name, $do_stripslashes=true){
if(isset($_POST[$name]))
return $do_stripslashes ? stripslashes_deep($_POST[$name]) : $_POST[$name];
return "";
}
}
if(!function_exists("rgar")){
function rgar($array, $name){
if(isset($array[$name]))
return $array[$name];
return '';
}
}
if(!function_exists("rgempty")){
function rgempty($name, $array = null){
if(!$array)
$array = $_POST;
$val = rgget($name, $array);
return empty($val);
}
}
if(!function_exists("rgblank")){
function rgblank($text){
return empty($text) && strval($text) != "0";
}
}
?>
/*
Plugin Name: MHR-Custom-Anti-Copy
Plugin URI: http://www.mahadirlab.com/en/mhr-custom-anti-copy/
Description: Prevent page selection (using mouse or ctrl+A) and Right Click via shortcodes .
Version: 1.1.0
Author: Mahadir Ahmad
Author URI: http://www.mahadirlab.com/en/
*/
/*
Copyright (C) 2011 Mahadir Ahmad
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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
function mhr_shortcode1() //anti select
{
echo '';
}
function mhr_shortcode2() // anti right click without message
{
echo ' ' ;
}
function mhr_shortcode4() //both
{
echo '';
echo ' ' ;
}
//insert javascript function file
function main_func()
{
$current_url = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));
echo '';
}
function setting_all()
{
$MHR_set_all_rclick = get_option('MHR_set_all_rclick');
$MHR_set_all_select = get_option('MHR_set_all_select');
$msg = get_option('MHR_msg');
if ($MHR_set_all_rclick == 1)
{
echo ' ' ;
}
if ($MHR_set_all_select == 1)
echo '';
}
function MHR_Anti_Copy_options_page()
{
$current_url = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));
echo '
MHR Custom Anti Copyversion 1.0
' ;
echo '
SETTING PAGE
' ;
if($_POST['MHR_save']){
update_option('MHR_msg',$_POST['MHR_msg']);
update_option('MHR_set_all_rclick',$_POST['MHR_set_all_rclick']);
update_option('MHR_set_all_select',$_POST['MHR_set_all_select']);
echo '
';
}
$MHR_set_all_rclick = get_option('MHR_set_all_rclick');
$MHR_set_all_select = get_option('MHR_set_all_select');
$msg = get_option('MHR_msg');
if ($msg =='')
update_option('MHR_msg','This function is disabled!');
function chkcheckbox($a) {
if ($a == 1)
return 'checked="yes"' ;
}
echo '

';
echo '
' ;
}
function MHR_anti_copy_setting()
{
if (function_exists('add_submenu_page')) {
add_options_page('MHR-Custom-Anti-Copy', 'MHR-Custom-Anti-Copy', 9, basename(__FILE__),'MHR_Anti_Copy_options_page');
}
}
add_shortcode('anti-select', 'mhr_shortcode1');
add_shortcode('anti-rclick', 'mhr_shortcode2');
add_shortcode('anti-both', 'mhr_shortcode4');
add_action('wp_head','main_func');
add_action('wp_footer','setting_all');
add_action('admin_menu','MHR_anti_copy_setting',1);
?>
/*
Plugin Name: CSS3 Pricing Tables WPress
Plugin URI: http://yougapi.com/products/wp/demo/pricing-tables/
Description: Integrate Awesome CSS3 Pricing tables into your WordPress.
Version: 1.2
Author: Yougapi Technology LLC
Author URI: http://yougapi.com
*/
require_once dirname( __FILE__ ).'/include/wpress_framework/WPress_framework.php';
require_once dirname( __FILE__ ).'/pricing_wpress_db.php';
//require_once dirname( __FILE__ ).'/pricing_wpress_settings.php';
require_once dirname( __FILE__ ).'/pricing_wpress_display.php';
class Pricing_wpress {
function Pricing_wpress() {
if(is_admin()) {
require_once dirname( __FILE__ ).'/pricing_wpress_admin.php';
//activation
register_activation_hook(__FILE__, array(__CLASS__, 'on_plugin_activation'));
//AJAX
add_action( 'wp_ajax_nopriv_pricing_wpress_listener', array(__CLASS__, 'pricing_wpress_listener') );
add_action( 'wp_ajax_pricing_wpress_listener', array(__CLASS__, 'pricing_wpress_listener') );
}
add_filter('the_posts', array(__CLASS__, 'add_css'));
//add_filter('wp_enqueue_scripts', array(__CLASS__, 'add_css'));
//shortcodes
add_shortcode( 'pricing_wpress', array(__CLASS__, 'display_pricing_table') );
}
function add_css($posts){
if (empty($posts)) return $posts;
$pos = stripos($posts[0]->post_content, '[pricing_wpress');
if($pos>=0) {
//find the style id
$shortcode_found = substr($posts[0]->post_content,$pos,50);
$style_pos = stripos($shortcode_found, 'style="');
$style_shortcode = substr($shortcode_found,$style_pos,10);
preg_match('/[0-9]/', $style_shortcode, $matches);
$style = $matches[0];
//which style?
if($style==1) $style_page='style_1';
elseif($style==2) $style_page='style_2';
elseif($style==3) $style_page='style_3';
elseif($style==4) $style_page='style_4';
elseif($style==5) $style_page='style_5';
elseif($style==6) $style_page='style_6';
elseif($style==7) $style_page='style_7';
elseif($style==8) $style_page='style_8';
else $style_page='style_1';
wp_enqueue_style( 'pricing_table_main', plugin_dir_url( __FILE__ ).'include/css/main.css');
wp_enqueue_style( 'pricing_table_style1', plugin_dir_url( __FILE__ ).'include/css/'.$style_page.'.css');
}
return $posts;
}
//display through a shortcode
function display_pricing_table($atts, $content = null, $code) {
extract(shortcode_atts(array(
'id' => '',
'style' => ''
), $atts));
if($style=='') $style='1';
$d1 = new Pricing_wpress_display();
$pricing_table = $d1->get_pricing_table($id);
return ''.$pricing_table.'
';
}
//AJAX calls
function pricing_wpress_listener() {
$method = $_POST['method'];
if($method=='save_pricing_table_structure') {
//post data
$id = $_POST['id'];
$name = $_POST['name'];
$nb_columns = $_POST['nb_columns'];
$nb_lines = $_POST['nb_lines'];
$line_height = $_POST['line_height'];
$columns_width = $_POST['columns_width'];
$caption_columns_width = $_POST['caption_columns_width'];
$currency = $_POST['currency'];
$caption_column_state = $_POST['caption_column_state'];
$db1 = new Pricing_wpress_db();
//Add a new table
if($id=='') {
$inserted_id = $db1->add_pricing_table(array('name'=>$name, 'nb_columns'=>$nb_columns, 'nb_lines'=>$nb_lines, 'line_height'=>$line_height, 'columns_width'=>$columns_width, 'caption_columns_width'=>$caption_columns_width, 'currency'=>$currency, 'caption_column_state'=>$caption_column_state));
echo $inserted_id;
}
//Edit existing table
else {
$db1->update_pricing_table_structure(array('name'=>$name, 'nb_columns'=>$nb_columns, 'nb_lines'=>$nb_lines, 'line_height'=>$line_height, 'columns_width'=>$columns_width, 'caption_columns_width'=>$caption_columns_width, 'currency'=>$currency, 'caption_column_state'=>$caption_column_state), $id);
echo $id;
}
}
else if($method=='save_table_content') {
$id = $_POST['id'];
$content = stripslashes($_POST['content']);
//$content = $_POST['content'];
$nb_columns = $_POST['nb_columns'];
$nb_lines = $_POST['nb_lines'];
//print_r($content);
if($id!=''&&$nb_columns>0&&$nb_lines>0) {
$content = json_decode($content,true);
//print_r($content);
$table_content = self::format_table_content($content, $nb_columns, $nb_lines);
//print_r($table_content);
$db1 = new Pricing_wpress_db();
$db1->update_pricing_table_content(array('table_content'=>$table_content), $id);
}
}
else if($method=='delete_table') {
$id = $_POST['id'];
if($id!='') {
$db1 = new Pricing_wpress_db();
$db1->delete_pricing_table($id);
}
}
exit;
}
function on_plugin_activation() {
$db1 = new Pricing_wpress_db();
$db1->create_pricing_table();
}
function format_table_structure($table) {
$nb_columns = '"nb_columns":"'.$table['nb_columns'].'"';
$nb_lines = '"nb_lines":"'.$table['nb_lines'].'"';
$line_height = '"line_height":"'.$table['line_height'].'"';
$columns_width = '"columns_width":"'.$table['columns_width'].'"';
$caption_columns_width = '"caption_columns_width":"'.$table['caption_columns_width'].'"';
$currency = '"currency":"'.$table['currency'].'"';
$caption_column_state = '"caption_column_state":"'.$table['caption_column_state'].'"';
$table_structure = $nb_columns.','.$nb_lines.','.$line_height.','.$columns_width.','.$caption_columns_width.','.$currency.','.$caption_column_state;
return $table_structure;
}
function format_table_content($content, $nb_columns, $nb_lines) {
$caption_header = urldecode($content['caption_header']);
$caption_header = str_replace('"',"",$caption_header); //delete any "
$caption_header = '"'.addslashes($caption_header).'"';
$caption_title = self::simple_array_to_json($content['caption_title']);
$column_title = self::simple_array_to_json($content['column_title']);
$column_price = self::simple_array_to_json($content['column_price']);
$column_note = self::simple_array_to_json($content['column_note']);
$button_title = self::simple_array_to_json($content['button_title']);
$button_link = self::simple_array_to_json($content['button_link']);
if($caption_header=='') $caption_header='""';
if($caption_title=='') $caption_title='""';
if($column_title=='') $column_title='""';
if($column_price=='') $column_price='""';
if($column_note=='') $column_note='""';
if($button_title=='') $button_title='""';
if($button_link=='') $button_link='""';
$caption_header = '"caption_header":'.$caption_header;
$caption_title = '"caption_title":'.$caption_title;
$column_title = '"column_title":'.$column_title;
$column_price = '"column_price":'.$column_price;
$column_note = '"column_note":'.$column_note;
$button_title = '"button_title":'.$button_title;
$button_link = '"button_link":'.$button_link;
//adjustement because index 0 is always empty...
if(count($content['line'])>$nb_columns) $nb_columns=count($content['line']);
for($i=0; $i<$nb_columns; $i++) {
$line .= self::simple_array_to_json($content['line'][$i]);
if($i<($nb_columns-1)) $line .= ',';
}
if($line!='') $line = '"line":['.$line.']';
else $line = '"line":""';
$json_str = '"content":{'.$caption_header.','.$caption_title.','.$column_title.','.$column_price.','.$column_note.','.$button_title.','.$button_link.','.$line.'}';
return $json_str;
}
//Receives one dimension array and returns a json format
function simple_array_to_json($array) {
$str='';
for($i=0; $i
/*
Plugin Name: Zopim Widget
Plugin URI: http://www.zopim.org
Description: Zopim embeds a chatbar on your website, so that any visitor can chat with you directly by clicking on the chatbar.
Author: Zopim
Version: 1.1.3
Author URI: http://www.zopim.com/
*/
define('ZOPIM_SCRIPT_DOMAIN', "zopim.com");
define('ZOPIM_BASE_URL', "https://www.zopim.com/");
define('ZOPIM_GETACCOUNTDETAILS_URL', ZOPIM_BASE_URL."plugins/getAccountDetails");
define('ZOPIM_SETDISPLAYNAME_URL', ZOPIM_BASE_URL."plugins/setDisplayName");
define('ZOPIM_IMINFO_URL', ZOPIM_BASE_URL."plugins/getImSetupInfo");
define('ZOPIM_IMREMOVE_URL', ZOPIM_BASE_URL."plugins/removeImSetup");
define('ZOPIM_LOGIN_URL', ZOPIM_BASE_URL."plugins/login");
define('ZOPIM_SIGNUP_URL', ZOPIM_BASE_URL."plugins/createTrialAccount");
define('ZOPIM_THEMES_LIST', "http://zopim.com/assets/dashboard/themes/window/plugins-themes.txt");
define('ZOPIM_COLORS_LIST', "http://zopim.com/assets/dashboard/themes/window/plugins-colors.txt");
define('ZOPIM_LANGUAGES_URL', "http://translate.zopim.com/projects/zopim/");
define('ZOPIM_DASHBOARD_URL', "http://dashboard.zopim.com/");
define('ZOPIM_SMALL_LOGO', "http://zopim.com/assets/branding/zopim.com/chatman/online.png");
define('ZOPIM_IM_LOGOS', "http://www.zopim.com/static/images/im/");
define('ZOPIM_THEMES_URL', "http://");
define('ZOPIM_COLOURS_URL', "http://");
require_once dirname( __FILE__ ) . '/accountconfig.php';
require_once dirname( __FILE__ ) . '/customizewidget.php';
require_once dirname( __FILE__ ) . '/imintegration.php';
// We need some CSS to position the paragraph
function zopimme() {
global $current_user, $zopimshown;
$code = get_option('zopimCode');
if (($code == "" || $code=="zopim") && (!ereg("zopim", $_GET["page"]))&& (!ereg("zopim", $_SERVER["SERVER_NAME"]))) { return; }
// dont show this more than once
if (isset($zopimshown) && $zopimshown == 1) { return; }
$zopimshown = 1;
echo "
";
$theoptions = array();
if (get_option('zopimLang') != "" && get_option('zopimLang') != "--")
$theoptions[] = " language: '".get_option('zopimLang')."'";
if (isset($current_user) && get_option("zopimGetVisitorInfo") == "checked") {
$ul = $current_user->data->first_name;
$useremail = $current_user->data->user_email;
if ($ul!="" && $useremail != "")
$theoptions[] = "name: '$ul', email: '$useremail'";
}
echo "\n";
}
function zopim_create_menu() {
//create new top-level menu
add_menu_page('Account Configuration', 'Zopim Chat', 'administrator', 'zopim_account_config', 'zopim_account_config', ZOPIM_SMALL_LOGO);
// add_submenu_page('zopim_about', "About", "About", "administrator", 'zopim_about', 'zopim_about');
add_submenu_page('zopim_account_config', 'Account Configuration', 'Account Setup', 'administrator', 'zopim_account_config', 'zopim_account_config');
add_submenu_page('zopim_account_config', 'Customize Widget', 'Customize', 'administrator', 'zopim_customize_widget', 'zopim_customize_widget');
add_submenu_page('zopim_account_config', 'IM Integration', 'IM Chat Bots', 'administrator', 'zopim_instant_messaging', 'zopim_instant_messaging');
add_submenu_page('zopim_account_config', 'Dashboard', 'Dashboard', 'administrator', 'zopim_dashboard', 'zopim_dashboard');
//call register settings function
add_action( 'admin_init', 'register_mysettings' );
}
function check_zopimCode() {
/*
// if (get_option('zopimCode') == '' && ($_GET["page"] != "zopim_account_config")) {
if (ereg("zopim", $_GET["page"] )) {
//add_action( 'admin_notices', create_function( '', 'echo "";' ) );
add_action( 'admin_notices', create_function( '', 'echo "This Zopim plugin is a work in progress. We will launch on the 25th of January. Thank you for your interest.
";' ) );
}
*/
return false;
}
function zopim_loader() {
add_action( 'admin_menu', 'check_zopimCode' );
}
add_action( 'init', 'zopim_loader' );
function zopim_about() {
echo "about";
}
function zopim_dashboard() {
echo ' You may also access the dashboard in a new window.
';
}
// Register the option settings we will be using
function register_mysettings() {
// Authentication and codes
register_setting( 'zopim-settings-group', 'zopimCode' );
register_setting( 'zopim-settings-group', 'zopimUsername' );
register_setting( 'zopim-settings-group', 'zopimSalt' );
register_setting( 'zopim-settings-group', 'zopimUseSSL' );
// General Widget settings
register_setting( 'zopim-settings-group', 'zopimGetVisitorInfo' );
register_setting( 'zopim-settings-group', 'zopimLang' );
// Chat button settings
register_setting( 'zopim-settings-group', 'zopimPosition' );
register_setting( 'zopim-settings-group', 'zopimHideOnOffline' );
register_setting( 'zopim-settings-group', 'zopimBubbleTitle' );
register_setting( 'zopim-settings-group', 'zopimBubbleText' );
register_setting( 'zopim-settings-group', 'zopimBubbleEnable' );
register_setting( 'zopim-settings-group', 'zopimUseBubble' );
// Themes / Color
register_setting( 'zopim-settings-group', 'zopimColor' );
register_setting( 'zopim-settings-group', 'zopimTheme' );
// Message Settings
register_setting( 'zopim-settings-group', 'zopimGreetings' );
register_setting( 'zopim-settings-group', 'zopimUseGreetings' );
get_option('zopimCode') == "" && update_option('zopimCode', "zopim");
get_option('zopimBubbleTitle') == "" && update_option('zopimBubbleTitle', "Questions?");
get_option('zopimBubbleText') == "" && update_option('zopimBubbleText', "Click here to chat with us!");
get_option('zopimBubbleEnable') == "" && update_option('zopimBubbleEnable', "checked");
get_option('zopimUseGreetings') == "" && update_option('zopimUseGreetings', "disabled");
get_option('zopimUseBubble') == "" && update_option('zopimUseBubble', "disabled");
get_option('zopimGreetings') == "" && update_option('zopimGreetings', '{"away":{"window":"If you leave a question or comment, our agents will be notified and will try to attend to you shortly =)","bar":"Click here to chat"},"offline":{"window":"We are offline, but if you leave your message and contact details, we will try to get back to you =)","bar":"Leave a message"},"online":{"window":"Leave a question or comment and our agents will try to attend to you shortly =)","bar":"Click here to chat"}}');
}
add_action('get_footer', 'zopimme');
// create custom plugin settings menu
add_action('admin_menu', 'zopim_create_menu');
function do_post_request($url, $_data, $optional_headers = null)
{
if (get_option('zopimUseSSL') != "zopimUseSSL")
$url = str_replace("https", "http", $url);
$data = array();
while(list($n,$v) = each($_data)){
$data[] = urlencode($n)."=".urlencode($v);
}
$data = implode('&', $data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
function json_to_array($json) {
require_once('JSON.php');
$jsonparser = new Services_JSON();
return ($jsonparser->decode($json));
}
function to_json($variable) {
require_once('JSON.php');
$jsonparser = new Services_JSON();
return ($jsonparser->encode($variable));
}
function getAccountDetails($salt) {
$salty = array("salt" => get_option('zopimSalt'));
return json_to_array(do_post_request(ZOPIM_GETACCOUNTDETAILS_URL, $salty));
}
function curl_get_url($filename) {
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $filename);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
return $file_contents;
}
?>
/*-----------------------------------------------------------------------------------*/
/* Start WooThemes Functions - Please refrain from editing this section */
/*-----------------------------------------------------------------------------------*/
// Set path to WooFramework and theme specific functions
$functions_path = TEMPLATEPATH . '/functions/';
$includes_path = TEMPLATEPATH . '/includes/';
// WooFramework
require_once ($functions_path . 'admin-init.php'); // Framework Init
// Theme specific functionality
require_once ($includes_path . 'theme-options.php'); // Options panel settings and custom settings
require_once ($includes_path . 'theme-functions.php'); // Custom theme functions
require_once ($includes_path . 'theme-plugins.php'); // Theme specific plugins integrated in a theme
require_once ($includes_path . 'theme-actions.php'); // Theme actions & user defined hooks
require_once ($includes_path . 'theme-comments.php'); // Custom comments/pingback loop
require_once ($includes_path . 'theme-js.php'); // Load javascript in wp_head
require_once ($includes_path . 'sidebar-init.php'); // Initialize widgetized areas
require_once ($includes_path . 'theme-widgets.php'); // Theme widgets
/*-----------------------------------------------------------------------------------*/
/* End WooThemes Functions - You can add custom functions below */
/*-----------------------------------------------------------------------------------*/
?>