Skip to content

Commit c4f02e7

Browse files
committed
Initial commit: Copy from wporg SVN /trunk
0 parents  commit c4f02e7

51 files changed

Lines changed: 46395 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

assets/icon.png

317 Bytes
Loading

assets/icon32.png

625 Bytes
Loading

assets/screenshot-1.png

94.9 KB
Loading

assets/screenshot-2.png

76.7 KB
Loading

assets/style.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#adminmenu #toplevel_page_sentinote-core-settings div.wp-menu-image img{
2+
position:relative;
3+
top:-2px;
4+
}
5+
#adminmenu #toplevel_page_sentinote-core-settings .current div.wp-menu-image img{
6+
opacity: 1.0 !important;
7+
}

inc/activate.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
/**
3+
* @copyright 2013-2014 Rheinard Korf
4+
*
5+
* @license http://opensource.org/licenses/GPL-2.0 GNU General Public License, version 2 (GPL-2.0)
6+
*
7+
* This program is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License, version 2, as
9+
* published by the Free Software Foundation.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
19+
* MA 02110-1301 USA
20+
*
21+
*/
22+
23+
// Add the sentinote menu
24+
function rksnwp_add_sentinote_menu() {
25+
$menu = apply_filters( 'sentinote_menu_name_filter', __('Sentinote Menu') );
26+
$menu_exists = wp_get_nav_menu_object( $menu );
27+
if( !$menu_exists ){
28+
$menu_id = wp_create_nav_menu( $menu );
29+
}
30+
}
31+
add_action('sentinote_core_activated', 'rksnwp_add_sentinote_menu');
32+
33+
// Add other cron options
34+
function rksnwp_cron_add_five( $schedules ){
35+
$schedules['five'] = array(
36+
'interval' => 300,
37+
'display' => __('Every Five Minutes', 'sentinote_tdom')
38+
);
39+
return $schedules;
40+
}
41+
add_filter( 'cron_schedules', 'rksnwp_cron_add_five' );
42+
43+
function rksnwp_cron_add_fifteen( $schedules ){
44+
$schedules['fifteen'] = array(
45+
'interval' => 900,
46+
'display' => __('Every Fifteen Minutes', 'sentinote_tdom')
47+
);
48+
return $schedules;
49+
}
50+
add_filter( 'cron_schedules', 'rksnwp_cron_add_fifteen' );
51+
52+
// Add default cron for every 5 minutes
53+
function rksnwp_add_default_cron() {
54+
if ( !wp_next_scheduled( 'rksnwp_every_x_minutes' ) ) {
55+
wp_schedule_event( time(), 'five', 'rksnwp_every_x_minutes');
56+
}
57+
}
58+
add_action('sentinote_core_activated', 'rksnwp_add_default_cron');
59+
60+
// Create action hook to perform tasks
61+
add_action( 'rksnwp_every_x_minutes', 'rksnwp_perform_tasks' );

inc/admin-page.php

Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
<?php
2+
/**
3+
* @copyright 2013-2014 Rheinard Korf
4+
*
5+
* @license http://opensource.org/licenses/GPL-2.0 GNU General Public License, version 2 (GPL-2.0)
6+
*
7+
* This program is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License, version 2, as
9+
* published by the Free Software Foundation.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
19+
* MA 02110-1301 USA
20+
*
21+
*/
22+
23+
function rksnwp_sentinote_core_admin_page(){
24+
global $rksnwp_options;
25+
global $rksnwp_url;
26+
27+
?>
28+
<div class="wrap">
29+
30+
<div id="icon-themes" class="icon32"></div>
31+
<h2><img src="<?php echo $rksnwp_url . 'assets/icon32.png'; ?>" width="20" height="20" /> <?php _e('Sentinote Settings','sentinote_tdom'); ?></h2>
32+
<?php settings_errors(); ?>
33+
34+
<?php
35+
$active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'sentinote_options';
36+
?>
37+
38+
<h2 class="nav-tab-wrapper">
39+
<a href="?page=sentinote-core-settings&tab=sentinote_options" class="nav-tab <?php echo $active_tab == 'sentinote_options' ? 'nav-tab-active' : ''; ?>"><?php _e('Sentinote Core','sentinote_tdom'); ?></a>
40+
<a href="?page=sentinote-core-settings&tab=evernote_options" class="nav-tab <?php echo $active_tab == 'evernote_options' ? 'nav-tab-active' : ''; ?>"><?php _e('Evernote Extension','sentinote_tdom'); ?></a>
41+
</h2>
42+
43+
<form method="post" action="options.php">
44+
<?php do_action( 'sentinote_settings', $active_tab ); ?>
45+
<hr />
46+
<?php submit_button(); ?>
47+
</form>
48+
49+
</div>
50+
<?php
51+
}
52+
53+
// Add tab for Sentinote Options
54+
function rksnwp_add_core_settings($active_tab) {
55+
global $rksnwp_options;
56+
57+
58+
$rksnwp_options['core'] = get_option('rksnwp_core_settings');
59+
if( $active_tab == "sentinote_options" ){
60+
settings_fields('rksnwp_core_settings_group');
61+
// do_settings_sections( 'rksnwp_core_settings_group' );
62+
?>
63+
<h3><?php _e('Sentinote Frequency','sentinote_tdom');?></h3>
64+
<p>
65+
<label class="description" for="rksnwp_core_settings[schedule]"><?php _e('Select how often you would like to update.', 'sentinote_tdom'); ?></label>
66+
<select name="rksnwp_core_settings[schedule]" id="rksnwp_core_settings[schedule]">
67+
<?php
68+
$current_schedule = wp_get_schedule( 'rksnwp_every_x_minutes' );
69+
$schedule_array = wp_get_schedules();
70+
$option_array = array_keys($schedule_array);
71+
?>
72+
<?php foreach($option_array as $option_item) { ?>
73+
<?php if($rksnwp_options['core']['schedule'] == $option_item || $option_item == $current_schedule ) { $selected = 'selected="selected"'; } else { $selected = ''; } ?>
74+
<option value="<?php echo $option_item; ?>" <?php echo $selected; ?>><?php echo $schedule_array[$option_item]['display'] ?></option>
75+
76+
<?php } ?>
77+
</select>
78+
</p>
79+
80+
<hr />
81+
82+
<h3><?php _e('Wordpress Defaults','sentinote_tdom');?></h3>
83+
84+
<!-- Default Author -->
85+
<p>
86+
<label class="description" for="rksnwp_core_settings[wp_author]"><?php _e('Default Author', 'sentinote_tdom'); ?></label>
87+
<select name="rksnwp_core_settings[wp_author]" id="rksnwp_core_settings[wp_author]">
88+
<?php
89+
$args = array(
90+
'exclude' => array()
91+
);
92+
$user_query = new WP_User_Query( $args );
93+
$option_array = $user_query->results;
94+
?>
95+
<?php foreach($option_array as $option_item) { ?>
96+
<?php if($rksnwp_options['core']['wp_author'] == $option_item->ID) { $selected = 'selected="selected"'; } else { $selected = ''; } ?>
97+
<option value="<?php echo $option_item->ID; ?>" <?php echo $selected; ?>><?php echo $option_item->display_name . ' (' . $option_item->user_nicename . ')'; ?></option>
98+
<?php } ?>
99+
</select>
100+
</p>
101+
102+
<!-- Default Category -->
103+
<p>
104+
<label class="description" for="rksnwp_core_settings[wp_category]"><?php _e('Default Category', 'sentinote_tdom'); ?></label>
105+
<select name="rksnwp_core_settings[wp_category]" id="rksnwp_core_settings[wp_category]">
106+
<?php
107+
$args = array(
108+
'type' => 'post',
109+
'taxonomy' => 'category',
110+
'hide_empty' => '0'
111+
);
112+
$option_array = get_categories( $args );
113+
?>
114+
<?php foreach($option_array as $option_item) { ?>
115+
<?php if($rksnwp_options['core']['wp_category'] == $option_item->cat_ID) { $selected = 'selected="selected"'; } else { $selected = ''; } ?>
116+
<option value="<?php echo $option_item->cat_ID; ?>" <?php echo $selected; ?>><?php echo $option_item->cat_name; ?></option>
117+
<?php } ?>
118+
</select>
119+
</p>
120+
121+
<hr />
122+
123+
<h3><?php _e('Markdown Settings','sentinote_tdom');?></h3>
124+
<p>Markdown is a way for you to write in plain text and then have it converted to HTML.</p>
125+
<p>See <a href="http://daringfireball.net/projects/markdown/basics" target="_blank">Markdown Basics</a> to get started. Sentinote also supports <a href="http://michelf.ca/projects/php-markdown/extra/" target="_blank">Markdown Extra</a> if you want some more advanced features.</p>
126+
<p>
127+
<?php if(!isset($rksnwp_options['core']['markdown'])) { $rksnwp_options['core']['markdown'] = 0; } ?>
128+
<input type="checkbox" id="rksnwp_core_settings[markdown]" name="rksnwp_core_settings[markdown]" value="1" <?php checked('1', $rksnwp_options['core']['markdown']); ?> />
129+
<label class="description" for="rksnwp_core_settings[markdown]"><?php _e('Enable Markdown. <small>(Will over-ride Evernote DIVs.)</small>','sentinote_tdom'); ?></label>
130+
</p>
131+
132+
<p>
133+
<?php if(!isset($rksnwp_options['core']['md_strip_html'])) { $rksnwp_options['core']['md_strip_html'] = 0; } ?>
134+
<input type="checkbox" id="rksnwp_core_settings[md_strip_html]" name="rksnwp_core_settings[md_strip_html]" value="1" <?php checked('1', $rksnwp_options['core']['md_strip_html']); ?> />
135+
<label class="description" for="rksnwp_core_settings[md_strip_html]"><?php _e('Strip all non-essential HTML before applying Markdown. <small>(All font changes will be stripped: color, family, size)</small>','sentinote_tdom'); ?></label>
136+
</p>
137+
138+
139+
140+
<hr />
141+
142+
<?php submit_button( 'Manual Sync Now', 'secondary', 'manual_sync_sentinote', true ); ?>
143+
<?php
144+
}
145+
}
146+
add_action( 'sentinote_settings', 'rksnwp_add_core_settings' );
147+
148+
// Add tab for Evernote Options
149+
function rksnwp_add_evernote_settings($active_tab) {
150+
global $rksnwp_options;
151+
$rksnwp_options['evernote'] = get_option('rksnwp_evernote_settings');
152+
if( $active_tab == "evernote_options" ){
153+
settings_fields('rksnwp_evernote_settings_group');
154+
// do_settings_sections( 'rksnwp_evernote_settings_group' );
155+
?>
156+
<h3><?php _e('Evernote Account Settings','sentinote_tdom');?></h3>
157+
<p class="description">To start using Sentinote you will need to get a developer token from: <a href="https://www.evernote.com/api/DeveloperToken.action">Evernote Developer Token</a>.</p>
158+
<p>
159+
<label class="description" for="rksnwp_evernote_settings[auth_token]"><?php _e('Evernote Developer Token','sentinote_tdom'); ?></label>
160+
<input type="text" id="rksnwp_evernote_settings[auth_token]" name="rksnwp_evernote_settings[auth_token]]" value="<?php echo $rksnwp_options['evernote']['auth_token']; ?>" style="min-width:400px;" />
161+
</p>
162+
<p class="description">Type the name of your notebook exactly as it appears in Evernote. Try to avoid symbols.</p>
163+
<p>
164+
<label class="description" for="rksnwp_evernote_settings[primary_notebook]"><?php _e('Evernote Notebook','sentinote_tdom'); ?></label>
165+
<input type="text" id="rksnwp_evernote_settings[primary_notebook]" name="rksnwp_evernote_settings[primary_notebook]" value="<?php echo $rksnwp_options['evernote']['primary_notebook']; ?>" />
166+
</p>
167+
168+
<h3><?php _e('Note Settings (<small>Evernote Specific Tweaks</small>)','sentinote_tdom');?></h3>
169+
170+
<p>
171+
<?php if(!isset($rksnwp_options['evernote']['div_to_p'])) { $rksnwp_options['evernote']['div_to_p'] = 1; } ?>
172+
<input type="checkbox" id="rksnwp_evernote_settings[div_to_p]" name="rksnwp_evernote_settings[div_to_p]" value="1" <?php checked('1', $rksnwp_options['evernote']['div_to_p']); ?> />
173+
<label class="description" for="rksnwp_evernote_settings[div_to_p]"><?php _e('Change Evernote DIVs to P tags. <small>(Fixes some spacing issues.)</small>','sentinote_tdom'); ?></label>
174+
</p>
175+
176+
177+
<?php
178+
}
179+
}
180+
add_action( 'sentinote_settings', 'rksnwp_add_evernote_settings' );
181+
182+
// Add Sentinote Admin Menu Link
183+
function rksnwp_add_option_link(){
184+
global $rksnwp_url;
185+
add_menu_page( 'Sentinote', 'Sentinote', 'manage_options', 'sentinote-core-settings', 'rksnwp_sentinote_core_admin_page', $rksnwp_url . 'assets/icon.png' );
186+
}
187+
add_action('admin_menu', 'rksnwp_add_option_link');
188+
189+
// Sentinote Settings Action Hook
190+
function rksnwp_core_admin_init() {
191+
do_action( 'sentinote_register_settings' );
192+
}
193+
add_action('admin_init', 'rksnwp_core_admin_init');
194+
195+
// Register Sentinote Core Settings
196+
function rksnwp_register_core_settings() {
197+
register_setting('rksnwp_core_settings_group', 'rksnwp_core_settings', 'rksnwp_core_settings_process');
198+
}
199+
add_action('sentinote_register_settings', 'rksnwp_register_core_settings');
200+
201+
// Process Sentinote Core Settings
202+
function rksnwp_core_settings_process( $core_settings ) {
203+
global $rksnwp_options;
204+
205+
// Manual Sync
206+
if( isset( $_POST['manual_sync_sentinote'] ) ){
207+
rksnwp_perform_tasks();
208+
$message_id = 'notify_sentinote_manual_sync';
209+
$message = __('Sentinote Successfully Synced.', 'sentinote_tdom');
210+
$type = 'updated';
211+
add_settings_error($message_id, esc_attr( 'settings_updated' ), $message, $type);
212+
}
213+
214+
// Change schedule
215+
if ( isset( $_POST['rksnwp_core_settings']['schedule'] ) ){
216+
if($rksnwp_options['core']['schedule'] != $_POST['rksnwp_core_settings']['schedule']){
217+
wp_clear_scheduled_hook('rksnwp_every_x_minutes');
218+
wp_schedule_event( time(), $_POST['rksnwp_core_settings']['schedule'], 'rksnwp_every_x_minutes');
219+
}
220+
}
221+
222+
return $core_settings;
223+
}
224+
225+
// Register Evernote Settings
226+
function rksnwp_register_evernote_settings() {
227+
register_setting('rksnwp_evernote_settings_group', 'rksnwp_evernote_settings', 'rksnwp_evernote_settings_process');
228+
}
229+
add_action('sentinote_register_settings', 'rksnwp_register_evernote_settings');
230+
231+
// Process Evernote Settings
232+
function rksnwp_evernote_settings_process( $evernote_settings ) {
233+
return $evernote_settings;
234+
}
235+
236+
237+
238+

0 commit comments

Comments
 (0)