PluginProbe
oik / 2.0.1
oik v2.0.1
1.10 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.2 1.3 1.3.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.0.1 2.1 2.2 2.3 2.4 2.5 2.5.1 All 71 releases
oik / oik.php

oik.php in oik 2.0.1, at oik.php

230 lines 7.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: oik base plugin
4 Plugin URI: http://www.oik-plugins.com/oik
5 Description: Lazy smart shortcodes for displaying often included key-information and other WordPress content
6 Version: 2.0.1
7 Author: bobbingwide
8 Author URI: http://www.bobbingwide.com
9 License: GPL2
10
11 Copyright 2010-2013 Bobbing Wide (email : herb@bobbingwide.com )
12
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License version 2,
15 as published by the Free Software Foundation.
16
17 You may NOT assume that you can use any other version of the GPL.
18
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
23
24 The license for this software can likely be found here:
25 http://www.gnu.org/licenses/gpl-2.0.html
26
27 */
28 require_once( "oik_boot.inc" );
29
30 /* All of the oik plugins and many of the common functions include calls to bw_trace(), bw_trace2() or bw_backtrace() so we need to include bwtrace.inc
31 */
32 require_once( 'bwtrace.inc' );
33 require_once( "bobbfunc.inc" );
34 require_once( "bobbcomp.inc" );
35
36 /**
37 * Return the oik_version
38 *
39 * @returns string oik base plugin version number - from the WordPress plugin template
40 */
41 function oik_version() {
42 return bw_oik_version();
43 }
44
45
46 require_once( "oik-add-shortcodes.php" );
47
48 add_filter('widget_text', 'do_shortcode');
49 add_filter('the_title', 'do_shortcode' );
50 //add_filter('wpbody-content', 'do_shortcode' );
51 add_filter('wp_footer', 'do_shortcode' );
52
53 add_filter('get_the_excerpt', 'do_shortcode' );
54 add_filter('the_excerpt', 'do_shortcode' );
55 // The big question is... do we need to add this filter
56 // or can we rely on it having been already added
57 // Well it all depends on how add_filter works **?**
58 // add_filter('the_content', 'do_shortcode', 11 );
59 //add_filter('get_pages', 'do_shortcode' );
60
61 //$bw_options = get_option( 'bw_options' );
62
63 //add_action('wp_print_styles', 'oik_enqueue_stylesheets');
64 add_action('wp_enqueue_scripts', 'oik_enqueue_stylesheets');
65 add_action('init', 'oik_main_init' );
66
67 add_action( 'wp_ajax_oik_ajax_list_shortcodes', 'oik_ajax_list_shortcodes' );
68 add_action( 'wp_ajax_oik_ajax_load_shortcode_syntax', 'oik_ajax_load_shortcode_syntax' );
69 add_action( 'wp_ajax_oik_ajax_load_shortcode_help', 'oik_ajax_load_shortcode_help' );
70 //add_action( 'admin_enqueue_scripts', 'bw_button_options' );
71
72
73 add_filter( "attachment_fields_to_edit", "oik_attachment_fields_to_edit", null, 2 );
74 add_filter( "attachment_fields_to_save", "oik_attachment_fields_to_save", null, 2 );
75
76
77
78 /**
79 * Implement 'wp_enqueue_scripts' action enqueue the oik.css and $customCSS stylesheets as required
80 *
81 * oik.css contains styles for oik shortcodes. It is embedded if not specifically excluded.
82 * $customCSS is embedded only if selected on oik options
83 * If you want some of oik.css then copy the contents into custom.css and exclude oik.css
84 *
85 * Note: bwlink.css contains styles for the bobbingwide and oik branding colours
86 * It is now only enqueued by the oik-bob-bing-wide plugin
87 *
88 */
89 function oik_enqueue_stylesheets() {
90 $oikCSS = bw_get_option( 'oikCSS' );
91 // bw_trace2( $oikCSS, "oikCSS" );
92 if ( !$oikCSS ) {
93 wp_enqueue_style( 'oikCSS', WP_PLUGIN_URL . '/oik/oik.css' );
94 }
95 $customCSS = bw_get_option( 'customCSS' );
96 if ( !empty( $customCSS) ) {
97 $customCSSurl = get_stylesheet_directory_uri() . '/' . $customCSS;
98 // bw_trace( $customCSSurl, __FUNCTION__, __LINE__, __FILE__, "customCSSurl");
99 wp_register_style( 'customCSS', $customCSSurl );
100 wp_enqueue_style( 'customCSS' );
101 }
102 }
103
104 /**
105 * Implement the 'init' action
106 *
107 * start oik and let oik dependent plugins know it's OK to use the oik API
108 */
109 function oik_main_init() {
110 add_action( 'admin_menu', 'oik_admin_menu' );
111 add_action( "activate_plugin", "oik_load_plugins" );
112 add_action( 'network_admin_menu', "oik_network_admin_menu" );
113 add_action( "network_admin_notices", "oik_network_admin_menu" );
114 bw_load_plugin_textdomain();
115 do_action( 'oik_loaded' );
116 }
117
118 /**
119 * Implement the 'admin_menu' action
120 *
121 * Note: This comes before 'admin_init' and after '_admin_menu'
122 *
123 */
124 function oik_admin_menu() {
125 require_once( 'admin/oik-admin.inc' );
126 oik_options_add_page();
127 add_action('admin_init', 'oik_admin_init' );
128 do_action( 'oik_admin_menu' );
129 }
130
131 /**
132 * Implement the 'network_admin_menu'/'network_admin_notices' action for multisite
133 *
134 * network_admin_menu is used to determine if plugins need updating
135 * network_admin_notices is used in plugin dependency checking
136 */
137 function oik_network_admin_menu() {
138 static $actioned = null;
139 if ( !$actioned ) {
140 $actioned = current_filter();
141 require_once( 'admin/oik-admin.inc' );
142 oik_options_add_page();
143 add_action('admin_init', 'oik_admin_init' );
144 do_action( 'oik_admin_menu' );
145 } else {
146 bw_trace2( $actioned, "actioned" );
147 }
148 }
149
150
151 /**
152 * Implement 'admin_init'
153 */
154 function oik_admin_init() {
155 oik_options_init();
156 }
157
158 function oik_ajax_list_shortcodes() {
159 oik_require( 'shortcodes/oik-codes.php' );
160 $sc_list = bw_shortcode_list();
161 $sc_json = json_encode( $sc_list );
162 bw_trace2( $sc_json );
163 echo $sc_json;
164 die();
165 }
166
167 function oik_ajax_load_shortcode_syntax() {
168 oik_require( "includes/oik-sc-help.inc" );
169 $shortcode = bw_array_get( $_REQUEST, 'shortcode', 'oik' );
170 $sc_syntax = _bw_lazy_sc_syntax( $shortcode );
171 $sc_json = json_encode( $sc_syntax );
172 bw_trace2( $sc_json, "sc_json" );
173 echo $sc_json;
174 die();
175 }
176
177 function oik_ajax_load_shortcode_help() {
178 oik_require( "includes/oik-sc-help.inc" );
179 $shortcode = bw_array_get( $_REQUEST, 'shortcode', 'oik' );
180 bw_trace2( $shortcode, "shortcode" );
181 $sc_help = bw_lazy_sc_example( $shortcode );
182 bw_trace2( $sc_help, "sc_help" );
183 echo $sc_help;
184 bw_flush();
185 die();
186 }
187
188
189 /**
190 * Add the custom image link using the same method as the Portfolio slideshow plugin which used the method documented here:
191 * @link http://wpengineer.com/2076/add-custom-field-attachment-in-wordpress/
192 *
193 * This is the method that adds fields to the form. Paired with 'attachment_fields_to_save'
194 */
195 function oik_attachment_fields_to_edit( $form_fields, $post) {
196 bw_trace2( $form_fields );
197 // gobang();
198 $form_fields['bw_image_link'] = array(
199 "label" => __( "oik custom image link URL" ),
200 "input" => "text",
201 "value" => get_post_meta( $post->ID, "_bw_image_link", true )
202 );
203 // This doesn't work since the url uses the [html] field instead of [value]
204 // $form_fields['url']['value'] = get_post_meta( $post->ID, "_oik_nivo_image_link", true );
205 return $form_fields;
206 }
207
208 /**
209 * Save the "oik custom image link URL"
210 * We save the value even if it's blanked out.
211 * Note: The custom meta field is prefixed with an underscore but the field name is not.
212 * Paired with 'attachment_fields_to_edit'
213 */
214 function oik_attachment_fields_to_save( $post, $attachment) {
215 bw_trace2();
216 //gobang();
217 $link = bw_array_get( $attachment, "bw_image_link", null ) ;
218 //$link = bw_array_get( $attachment, "url", null ) ;
219
220 update_post_meta( $post['ID'], '_bw_image_link', $link );
221 return $post;
222 }
223
224
225
226
227
228
229
230