PluginProbe
oik / 2.5
oik v2.5
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.5, at oik.php

257 lines 9.0 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-plugins/oik
5 Description: OIK Information Kit - Over 80 lazy smart shortcodes for displaying WordPress content
6 Version: 2.5
7 Author: bobbingwide
8 Author URI: http://www.oik-plugins.com/author/bobbingwide
9 Text Domain: oik
10 Domain Path: /languages/
11 License: GPLv2 or later
12 License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
14 Copyright 2010-2015 Bobbing Wide (email : herb@bobbingwide.com )
15
16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License version 2,
18 as published by the Free Software Foundation.
19
20 You may NOT assume that you can use any other version of the GPL.
21
22 This program is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 GNU General Public License for more details.
26
27 The license for this software can likely be found here:
28 http://www.gnu.org/licenses/gpl-2.0.html
29
30 */
31
32 /**
33 * Return the oik_version
34 *
35 * @returns string oik base plugin version number - from the WordPress plugin template
36 */
37 function oik_version() {
38 return bw_oik_version();
39 }
40
41 /**
42 * Function to invoke when the file has been loaded
43 *
44 * 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
45 * As of oik v2.3 the "init" action is invoked after most other plugins.
46 * This allows oik-fields and oik-types to define overrides to registered post types and taxonomies.
47 * In oik 2.4 I tried not calling oik_main_init() for AJAX requests but this was more troublesome than beneficial since
48 * there are many vanilla WordPress functions that can fail if post types are not registered.
49 *z
50 */
51 function oik_plugin_file_loaded() {
52 require_once( "oik_boot.inc" );
53 require_once( 'bwtrace.inc' );
54 require_once( "bobbfunc.inc" );
55 require_once( "oik-add-shortcodes.php" );
56
57 if ( defined('DOING_AJAX') && DOING_AJAX ) {
58 oik_require( "includes/oik-ajax.php" );
59 oik_ajax_lazy_init();
60 } else {
61 //require_once( "bobbcomp.inc" );
62 add_action('wp_enqueue_scripts', 'oik_enqueue_stylesheets', 11);
63 }
64 add_action( 'init', 'oik_main_init', 11 );
65
66 add_filter( "attachment_fields_to_edit", "oik_attachment_fields_to_edit", null, 2 );
67 add_filter( "attachment_fields_to_save", "oik_attachment_fields_to_save", null, 2 );
68 }
69
70 /**
71 * Implement 'wp_enqueue_scripts' action enqueue the oik.css and $customCSS stylesheets as required
72 *
73 * oik.css contains styles for oik shortcodes. It is embedded if not specifically excluded.
74 * $customCSS is embedded only if selected on oik options
75 * If you want some of oik.css then copy the contents into custom.css and exclude oik.css
76 *
77 * Note: bwlink.css contains styles for the bobbingwide and oik branding colours
78 * It is now only enqueued by the oik-bob-bing-wide plugin
79 *
80 */
81 function oik_enqueue_stylesheets() {
82 $oikCSS = bw_get_option( 'oikCSS' );
83 // bw_trace2( $oikCSS, "oikCSS" );
84 if ( !$oikCSS ) {
85 wp_enqueue_style( 'oikCSS', WP_PLUGIN_URL . '/oik/oik.css' );
86 }
87 $customCSS = bw_get_option( 'customCSS' );
88 if ( !empty( $customCSS) ) {
89 $customCSSurl = get_stylesheet_directory_uri() . '/' . $customCSS;
90 // bw_trace( $customCSSurl, __FUNCTION__, __LINE__, __FILE__, "customCSSurl");
91 wp_register_style( 'customCSS', $customCSSurl );
92 wp_enqueue_style( 'customCSS' );
93 }
94 }
95
96 /**
97 * Implement the 'init' action
98 *
99 * start oik and let oik dependent plugins know it's OK to use the oik API
100 */
101 function oik_main_init() {
102 add_action( 'admin_menu', 'oik_admin_menu' );
103 add_action( "activate_plugin", "oik_load_plugins" );
104 add_action( 'network_admin_menu', "oik_network_admin_menu" );
105 add_action( "network_admin_notices", "oik_network_admin_menu" );
106 add_action( "admin_bar_menu", "oik_admin_bar_menu", 20 );
107 add_action( 'login_head', 'oik_login_head');
108 bw_load_plugin_textdomain();
109 /**
110 * Tell plugins that oik has been loaded.
111 *
112 * This allows plugins which are dependent upon oik to start using the oik APIs
113 * It doesn't mean that all the APIs are available.
114 */
115 do_action( 'oik_loaded' );
116 }
117
118 /**
119 * Implement the 'admin_menu' action
120 *
121 * Note: This action comes before 'admin_init' and after '_admin_menu'
122 */
123 function oik_admin_menu() {
124 require_once( 'admin/oik-admin.inc' );
125 oik_options_add_page();
126 add_action('admin_init', 'oik_admin_init' );
127 do_action( 'oik_admin_menu' );
128 add_action('admin_enqueue_scripts', 'oik_enqueue_stylesheets', 11 );
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 * Implement 'admin_init' action
152 */
153 function oik_admin_init() {
154 oik_options_init();
155 }
156
157 /**
158 * Add the custom image link using the same method as the Portfolio slideshow plugin which used the method documented here:
159 * @link http://wpengineer.com/2076/add-custom-field-attachment-in-wordpress/
160 *
161 * This is the method that adds fields to the form. Paired with 'attachment_fields_to_save'
162 *
163 * Note: Although this filter is only invoked during image editing
164 * ( in admin processing ) it can't be registered during admin_init / admin_menu
165 * since it's not invoked that way
166 * i.e. Don't move the add_filter() logic for this filter.
167 */
168 function oik_attachment_fields_to_edit( $form_fields, $post) {
169 $form_fields['bw_image_link'] = array(
170 "label" => __( "oik custom image link URL", "oik" ),
171 "input" => "text",
172 "value" => get_post_meta( $post->ID, "_bw_image_link", true )
173 );
174 // This doesn't work since the url uses the [html] field instead of [value]
175 // $form_fields['url']['value'] = get_post_meta( $post->ID, "_oik_nivo_image_link", true );
176 return $form_fields;
177 }
178
179 /**
180 * Save the "oik custom image link URL"
181 *
182 * We save the value even if it's blanked out.
183 * Note: The custom meta field is prefixed with an underscore but the field name is not.
184 * Paired with 'attachment_fields_to_edit'
185 *
186 * See also comments for oik_attachment_fields_to_edit()
187 */
188 function oik_attachment_fields_to_save( $post, $attachment) {
189 $link = bw_array_get( $attachment, "bw_image_link", null ) ;
190 update_post_meta( $post['ID'], '_bw_image_link', $link );
191 return $post;
192 }
193
194 /**
195 * Implement "admin_bar_menu" action for oik
196 *
197 * We implement this first for the whole site...
198 * @TODO but allow each user to override it in oik-user?
199 *
200 * This action hook runs after other action hooks to alter the "Howdy," prefix for 'my-account'
201 * Most howdy replace plugins look for the string "Howdy," so the code won't work if the string has already been translated
202 * We look for the translated version, which includes the user's display name.
203 * So this logic should work localized versions.
204 *
205 * The structure we're changing is the node for 'my-account'
206 * e.g.
207 [id] => my-account
208 [parent] => top-secondary
209 [title] => Howdy, vsgloik<img alt='' onerror='this.src="http://qw/wordpress/wp-content/themes/rngs0721/images/no-avatar.jpg"' src='http://1.gravatar.com/avatar/1c32865f0cfb495334dacb5680181f2d?s=26&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D26&amp;r=G' class='avatar avatar-26 photo' height='26' width='26' />
210 [href] => http://qw/wordpress/wp-admin/profile.php
211 [meta] => Array
212 (
213 [class] => with-avatar
214 [title] => My Account
215 )
216 *
217 * @param WP_Admin_Bar $wp_admin_bar - the WP_Admin_Bar object
218 *
219 */
220 function oik_admin_bar_menu( &$wp_admin_bar ) {
221 $replace = bw_get_option( "howdy" );
222 if ( $replace ) {
223 $node = $wp_admin_bar->get_node( 'my-account' );
224 $current_user = wp_get_current_user();
225 $howdy = sprintf( __('Howdy, %1$s'), $current_user->display_name );
226 //bw_trace2( $node, "node" );
227 $replace = $replace . " " . $current_user->display_name;
228 if ( $node->title ) {
229 $node->title = str_replace( $howdy, $replace, $node->title );
230 $wp_admin_bar->add_node( $node );
231 }
232 }
233 }
234
235 /**
236 * Implement "login_head" action for oik
237 *
238 * Will use the user defined logo image as the login logo, if required
239 *
240 */
241 function oik_login_head() {
242 oik_require( "shortcodes/oik-logo.php" );
243 oik_lazy_login_head();
244 }
245
246 /**
247 * Initiate oik processing
248 */
249 oik_plugin_file_loaded();
250
251
252
253
254
255
256
257