forked from laposta/connect-wordpress
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaposta.php
More file actions
190 lines (150 loc) · 5.22 KB
/
laposta.php
File metadata and controls
190 lines (150 loc) · 5.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?php
/**
* @package Laposta
*/
/*
Plugin Name: Laposta
Plugin URI: http://laposta.nl/documentatie/wordpress.524.html
Description: Laposta is programma waarmee je gemakkelijk en snel nieuwsbrieven kunt maken en versturen. Met deze plugin plaats je snel een aanmeldformulier op je website.
Version: 1.3
Author: Laposta - Stijn van der Ree
Author URI: http://laposta.nl/contact
License: GPLv2 or later
*/
/*
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.
*/
// Make sure we don't expose any info if called directly
if ( !function_exists( 'add_action' ) ) {
echo 'Hi there! I\'m just a plugin, not much I can do when called directly.';
exit;
}
define('LAPOSTA_VERSION', '1.3');
define('LAPOSTA_PLUGIN_URL', plugin_dir_url( __FILE__ ));
if (!class_exists('Laposta_Template')) {
class Laposta_Template {
public function __construct() {
// registreer admin acties
add_action('admin_init', array(&$this, 'admin_init'));
add_action('admin_menu', array(&$this, 'add_menu'));
}
// bij activatie plugin
public static function activate() {
// Do nothing
}
// bij deactivatie plugin
public static function deactivate() {
// Do nothing
}
// hook into WP's admin_init action hook
public function admin_init() {
// Set up the settings for this plugin
$this->init_settings();
}
// Initialize some custom settings
public function init_settings() {
// register the settings for this plugin
register_setting('laposta_template-group', 'title');
register_setting('laposta_template-group', 'api_key');
register_setting('laposta_template-group', 'list');
}
// add a menu
public function add_menu() {
add_options_page('Laposta', 'Laposta', 'manage_options', 'laposta_template', array(&$this, 'plugin_settings_page'));
}
// Menu Callback
public function plugin_settings_page() {
if (!current_user_can('manage_options')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
// Render the settings template
include(sprintf("%s/templates/settings.php", dirname(__FILE__)));
}
}
}
if (class_exists('Laposta_Template')) {
// Installation and uninstallation hooks
register_activation_hook(__FILE__, array('Laposta_Template', 'activate'));
register_deactivation_hook(__FILE__, array('Laposta_Template', 'deactivate'));
// instantiate the plugin class
$laposta_template = new Laposta_Template();
// Add a link to the settings page onto the plugin page
if (isset($laposta_template)) {
// Add the settings link to the plugins page
function plugin_settings_link($links) {
$settings_link = '<a href="options-general.php?page=laposta_template">Settings</a>';
array_unshift($links, $settings_link);
return $links;
}
$plugin = plugin_basename(__FILE__);
add_filter("plugin_action_links_$plugin", 'plugin_settings_link');
}
}
// widget
if (!class_exists('Laposta_Widget')) {
class Laposta_Widget extends WP_Widget {
public function __construct() {
parent::__construct(
'laposta_widget', // Base ID
__('Laposta', 'text_domain'), // Name
array( 'description' => __( 'Aanmeldformulier', 'text_domain' ), ) // Args
);
}
public function init() {
register_widget('Laposta_Widget');
}
public function form($instance) {
// all settings inside plugin; do nothing
echo '<p>De widget kan ingesteld worden bij het Laposta plugin scherm.</p>';
}
public function update($new_instance, $old_instance) {
return $new_instance;
}
public function widget($args, $instance) {
// before and after widget arguments are defined by themes
echo $args['before_widget'];
$title = get_option('title');
if ($title) {
echo $args['before_title'] . $title . $args['after_title'];
}
// check availability list and api-key
$api_key = get_option('api_key');
$list = get_option('list');
if (!$api_key) {
echo 'Er is nog geen api-key ingevoerd. Dit kan bij de Settings van deze plugin.';
} else if (!$list) {
echo 'Er is nog geen lijst aangevinkt. Dit kan bij de Settings van deze plugin.';
}
if ($list && $api_key) {
// Laposta javascript
echo '
<div align="center">
<!-- Laposta 1.1 -->
<script type="text/javascript">
var Laposta = {};
Laposta.width = "96%";
</script>
<script type="text/javascript" src="https://wat-een-fantastische.email-provider.nl/a/' . get_option('list') . '/subscribe.js"></script>
<!-- /Laposta -->
</div>';
}
echo $args['after_widget'];
}
}
}
if (class_exists('Laposta_Widget')) {
add_action('widgets_init', 'register_laposta_widget');
function register_laposta_widget() {
register_widget('Laposta_Widget');
}
}