PluginProbe
oik / 1.17
oik v1.17
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 1.17, at oik.php

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