Skip to content

Commit 64f86fe

Browse files
authored
First upload
1 parent 30d1509 commit 64f86fe

File tree

2 files changed

+298
-0
lines changed

2 files changed

+298
-0
lines changed

rd_messenger/rd_messenger.php

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
<?php
2+
/*
3+
Plugin Name: Facebook Messenger
4+
Plugin URI: http://wordpress.org/plugins/rd_messenger/
5+
Description: A very simple plug-in that facilitates the process of adding facebook messenger to your website
6+
Author: Leszek Pomianowski
7+
Author URI: https://rapiddev.pl/
8+
License: MIT
9+
License URI: https://rapiddev.pl/license
10+
Version: 1.1.0
11+
Text Domain: rd_messenger
12+
Domain Path: /languages
13+
*/
14+
/**
15+
* @package WordPress
16+
* @subpackage Facebook Messenger
17+
*
18+
* @author Leszek Pomianowski
19+
* @copyright Copyright (c) 2017, RapidDev
20+
* @link https://www.rapiddev.pl/rd_messenger
21+
* @license https://www.rapiddev.pl/license
22+
*/
23+
24+
/* ====================================================================
25+
* Constant
26+
* ==================================================================*/
27+
define('RD_MESSENGER_VERSION', '1.1.0');
28+
define('RD_MESSENGER_PATH', plugin_dir_path( __FILE__ ));
29+
30+
/* ====================================================================
31+
* Define language files
32+
* ==================================================================*/
33+
function rd_messenger_languages()
34+
{
35+
load_theme_textdomain('rd_messenger', plugin_dir_path( __FILE__ ).'languages');
36+
}
37+
add_action('plugins_loaded', 'rd_messenger_languages');
38+
39+
/* ====================================================================
40+
* PHP Version verification
41+
* ==================================================================*/
42+
if (version_compare(PHP_VERSION, '5.4.0') >= 0)
43+
{
44+
45+
/* ====================================================================
46+
* WordPress Version check
47+
* ==================================================================*/
48+
global $wp_version;
49+
if (version_compare($wp_version, '4.5.0', '>='))
50+
{
51+
52+
/* ====================================================================
53+
* Add customization options
54+
* ==================================================================*/
55+
function rd_messenger_customizer($wp_customize)
56+
{
57+
#HTML Class
58+
if(class_exists('WP_Customize_Control') && ! class_exists('rd_messenger_html')){
59+
class rd_messenger_html extends WP_Customize_Control {
60+
public $content = '';
61+
public function render_content(){
62+
if (isset($this->label)){
63+
echo '<span class="customize-control-title">'.$this->label.'</span>';
64+
}
65+
if(isset($this->description)){
66+
echo '<span class="description customize-control-description">'.$this->description.'</span>';
67+
}
68+
if(isset($this->content)){
69+
echo $this->content;
70+
}
71+
}
72+
}
73+
}
74+
#Add section
75+
$wp_customize->add_section('rd_messenger',array('title'=>'Facebook Messenger','capability'=>'edit_theme_options','priority'=> 5));
76+
#Add enable checkbox setting
77+
$wp_customize->add_setting('rd_messenger_enable',array('default'=> false,'type'=>'theme_mod','capability'=>'edit_theme_options','transport'=>'refresh'));
78+
$wp_customize->add_control('rd_messenger_enable',array('type'=>'checkbox','priority'=>1,'section'=>'rd_messenger','label'=>__('Switch on the Facebook Messenger','rd_messenger')));
79+
#Add minimized checkbox setting
80+
$wp_customize->add_setting('rd_messenger_minimized',array('default'=> false,'type'=>'theme_mod','capability'=>'edit_theme_options','transport'=>'refresh'));
81+
$wp_customize->add_control('rd_messenger_minimized',array('type'=>'checkbox','priority'=>2,'section'=>'rd_messenger','label'=>__('Minimized (optional)','rd_messenger'),'description'=>__('Specifies whether the plugin should be minimized or shown. Defaults to true on desktop and false on mobile browsers.', 'rd_messenger')));
82+
#Add api key setting
83+
$wp_customize->add_setting('rd_messenger_api',array('default'=>null,'type'=>'theme_mod','capability'=>'edit_theme_options','transport'=>'refresh'));
84+
$wp_customize->add_control('rd_messenger_api',array('type'=>'text','priority'=> 3,'section'=>'rd_messenger','label' => __('API key','rd_messenger'),'description'=>__('Enter your application key here','rd_messenger')));
85+
#Add page id setting
86+
$wp_customize->add_setting('rd_messenger_page',array('default'=> null,'type'=>'theme_mod','capability'=>'edit_theme_options','transport'=>'refresh'));
87+
$wp_customize->add_control('rd_messenger_page',array('type'=>'text','priority'=>4,'section'=>'rd_messenger','label'=>__('Page ID','rd_messenger'),'description'=>__('Enter your numeric page id here','rd_messenger')));
88+
#Add webhook setting
89+
$wp_customize->add_setting('rd_messenger_webhook',array('default'=>null,'type'=>'theme_mod','capability'=>'edit_theme_options','transport'=>'refresh'));
90+
$wp_customize->add_control('rd_messenger_webhook',array('type'=>'text','priority'=> 5,'section'=>'rd_messenger','label' => __('Webhook (optional)','rd_messenger'),'description'=>__('Custom string passed to your webhook in messaging_postbacks and messaging_referrals events','rd_messenger')));
91+
#Description
92+
$wp_customize->add_setting('rd_messenger_html',array('transport' => 'refresh'));
93+
$wp_customize->add_control(new rd_messenger_html($wp_customize,'rd_messenger_html',array('section' => 'rd_messenger','priority' => 6,'content' =>
94+
'<hr /><a class="button button-secondary" style="width:100%;text-align:center" href="https://developers.facebook.com/docs/messenger-platform/reference/web-plugins/#customer_chat" target="_blank">Facebook Developers</a><p><small>'.__('Facebook and Facebook Messenger are registered trademarks of Facebook Inc.', 'rd_messenger').'</small></p>'
95+
)));
96+
}
97+
add_action('customize_register', 'rd_messenger_customizer');
98+
99+
/* ====================================================================
100+
* Footer action
101+
* ==================================================================*/
102+
function rd_messenger_footer()
103+
{
104+
$minimized = get_theme_mod('rd_messenger_minimized');
105+
$webhook = get_theme_mod('rd_messenger_webhook');
106+
if($minimized){$min = 'true';}else{$min = 'false';}
107+
if($webhook!=null){$web=' ref="'.$webhook.'"';}else{$web=null;}
108+
?>
109+
<div class="fb-customerchat" page_id="<?php echo get_theme_mod('rd_messenger_page') ?>" minimized="<?php echo $min; ?>"<?php echo $web; ?>></div><script async="async" defer="defer">window.fbAsyncInit = function() {FB.init({appId : '<?php echo get_theme_mod('rd_messenger_api') ?>',xfbml : true,version : 'v2.11'});FB.AppEvents.logPageView();};(function(d, s, id){var js, fjs = d.getElementsByTagName(s)[0];if (d.getElementById(id)) {return;}js = d.createElement(s); js.id = id;js.src = "https://connect.facebook.net/en_US/sdk.js";fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'facebook-jssdk'));</script>
110+
<?php
111+
}
112+
if (get_theme_mod('rd_messenger_enable'))
113+
{
114+
add_action('wp_footer', 'rd_messenger_footer');
115+
}
116+
117+
/* ====================================================================
118+
* WordPress <4.5.0 error
119+
* ==================================================================*/
120+
}else{
121+
if (!function_exists('rd_messenger_wordpress_error'))
122+
{
123+
function rd_messenger_wordpress_error()
124+
{
125+
?>
126+
<div class="notice notice-error">
127+
<p>
128+
<strong><?php _e('CRITICAL ERROR', 'rd_messenger') ?>!</strong>
129+
<br />
130+
<?php _e('The', 'rd_messenger'); ?> <i>Facebook Messenger</i> <?php _e('requires at least', 'rd_messenger') ?> WordPress 4.5.0
131+
<br />
132+
<?php _e('You need to update your WordPress site', 'rd_messenger') ?>.
133+
<br />
134+
<small><i><?php _e('ERROR ID', 'rd_messenger') ?>: 2</i></small>
135+
</p>
136+
</div>
137+
<?php
138+
}
139+
add_action('admin_notices', 'rd_messenger_wordpress_error');
140+
}
141+
}
142+
143+
/* ====================================================================
144+
* PHP <5.4.0 error
145+
* ==================================================================*/
146+
}else{
147+
if (!function_exists('rd_messenger_php_error'))
148+
{
149+
function rd_messenger_php_error()
150+
{
151+
?>
152+
<div class="notice notice-error">
153+
<p>
154+
<strong><?php _e('CRITICAL ERROR', 'rd_messenger') ?>!</strong>
155+
<br />
156+
<?php _e('The', 'rd_messenger'); ?> <i>Facebook Messenger</i> <?php _e('requires at least', 'rd_messenger') ?> PHP 5.4.0
157+
<br />
158+
<?php _e('You need to update your server', 'rd_messenger') ?>.
159+
<br />
160+
<small><i><?php _e('ERROR ID', 'rd_messenger') ?>: 1</i></small>
161+
</p>
162+
</div>
163+
<?php
164+
}
165+
add_action('admin_notices', 'rd_messenger_php_error');
166+
}
167+
}
168+
?>

rd_messenger/readme.txt

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
=== Spectrum Engine ===
2+
Contributors: RapidDev
3+
Donate link: https://paypal.me/rapiddev
4+
Tags: rapiddev, rapid, developing, facebook, messenger, chat, plugin, website, live, support, chatbot
5+
Requires at least: 4.5.0
6+
Tested up to: 4.9.1
7+
Requires PHP: 5.6.0
8+
Stable tag: rd_messenger
9+
License: MIT
10+
License URI: https://rapiddev.pl/license/
11+
12+
A very simple plug-in that facilitates the process of adding facebook messenger to your website
13+
14+
== Description ==
15+
16+
Spectrum Engine is a simple but very life-enhancing plugin for developers. With it you can quickly create custom Customizer menu and add your own options to it.
17+
With one `spectrum()` function, you have access to both modified and not yet edited options.
18+
You can add the spectrum as an element of your WordPress Theme and dramatically speed up your work.
19+
Spectrum Engine ready for theme is available at:
20+
https://github.com/rapiddtc
21+
22+
Note, the plugin includes an optional option, which is Google Fonts.
23+
If you do not remove this option, you must accept Google's terms and privacy policy.
24+
https://www.google.com/policies/privacy/
25+
https://developers.google.com/terms/
26+
27+
== Installation ==
28+
29+
1. Upload `rd_messenger` folder to the `/wp-content/plugins/` directory
30+
2. Activate the plugin through the 'Plugins' menu in WordPress
31+
3. Add your APP ID and Facebook page ID in Customizer
32+
33+
== Frequently asked questions ==
34+
35+
= What types of options are available? =
36+
37+
You can now use: HTML, CHECKBOX, URL, TEXT, TEXTAREA, SELECT, COLOR, IMG, PAGE, MULTIPAGE, DROPDOWN, MULTISELECT
38+
39+
= Where are my options kept? =
40+
41+
Options and menu layout are in `spectrum_engine/_options.php` file
42+
43+
= How to add my own option? =
44+
45+
You need to add an option to the matching section, as shown below:
46+
$options = [
47+
['section_id'] =>
48+
[
49+
['option_id', 'default_value', 'type', 'label', 'description', 'additional options']
50+
]
51+
];
52+
53+
= How create my own menu? =
54+
55+
You need to create a menu according to the scheme below:
56+
$customization = [
57+
['section_id'] =>
58+
[
59+
'Title',
60+
'Description'
61+
],
62+
['panel_id'] =>
63+
'Title',
64+
'Description',
65+
[
66+
['section_id', 'label', 'description']
67+
]
68+
];
69+
70+
== Screenshots ==
71+
72+
1. This is the file with options
73+
2. Dashboard with view of active options and menus
74+
3. Google fonts
75+
4. Available types of options
76+
77+
== Changelog ==
78+
79+
= 2.2.4 =
80+
1. Fixed an error when the main section has no description
81+
2. Fixed an error when the subsection has no description
82+
83+
= 2.2.3 =
84+
1. Fixed issue with Google fonts during customization
85+
86+
= 2.2.2 =
87+
1. Bug fixes
88+
89+
= 2.2.1 =
90+
1. Bug fixes
91+
92+
= 2.2.1 =
93+
1. Improved connectivity with files
94+
2. Bug fixes
95+
96+
= 2.1.0 =
97+
1. `spectrum()` function stores settings, works in personalization, and does not require so many database connections
98+
99+
= 2.0.0 =
100+
1. Completely rewritten engine revamp for Spectrum theme
101+
102+
= 1.3.0 =
103+
1. Bug fixes
104+
2. Added `cc("option_id")` functions as storing settings
105+
106+
= 1.2.0 =
107+
1. Bug fixes
108+
2. Added `global $cc;` as a variable storing settings
109+
110+
= 1.1.0 =
111+
1. Bug fixes
112+
2. Added support for PAGE, MULTIPAGE, DROPDOWN, MULTISELECT
113+
114+
= 1.0.0 =
115+
1. CCreation Engine was created for the CCreation theme
116+
2. Added support for HTML, CHECKBOX, URL, TEXT, TEXTAREA, SELECT, COLOR, IMG
117+
118+
== Upgrade notice ==
119+
The latest `spectrum()` functions works in personalization. Added support for Google fonts
120+
121+
122+
== License ==
123+
124+
Copyright 2017 RapidDev Leszek Pomianowski
125+
126+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
127+
128+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
129+
130+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)