-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple-pull-quote.php
executable file
·109 lines (90 loc) · 3.68 KB
/
simple-pull-quote.php
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
<?php
/**
* @package Simple Pull Quote
* @author Toby Cryns
* @version 1.5
*/
/*
Plugin Name: Simple Pull Quote
Plugin URI: http://www.themightymo.com/simple-pull-quote
Description: Easily add pull quotes to blog posts using shortcode.
Author: Toby Cryns
Version: 1.5
Author URI: http://www.themightymo.com/updates
*/
/* Copyright 2009 Toby Cryns (email : toby at themightymo dot com)
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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// Load the TinyMCE Stuff
require_once (dirname(__FILE__) . '/simple-pull-quote_tinymce.php');
function my_css() {
echo '<link type="text/css" rel="stylesheet" href="' . plugins_url( 'css/simple-pull-quote.css', __FILE__ ) . '" />' . "\n";
}
// Add the CSS file to the header when the page loads
add_action('wp_head', 'my_css');
/* Call the javascript file that loads the html editor button */
//add_action('admin_print_scripts', 'simplePullQuotes');
function simplePullQuotes() {
wp_enqueue_script(
'simple-pull-quotes',
plugin_dir_url(__FILE__) . 'simple-pull-quote.js',
array('quicktags')
);
}
// Load the custom TinyMCE plugin
function simple_pull_quotes_plugin( $plugins ) {
$plugins['simplepullquotes'] = plugins_url('/simple-pull-quote/tinymce3/editor_plugin.js');
return $plugins;
}
function specific_enqueue($hook_suffix) {
if( 'post.php' == $hook_suffix || 'post-new.php' == $hook_suffix ) {
add_action('admin_print_scripts', 'simplePullQuotes');
}
}
add_action( 'admin_enqueue_scripts', 'specific_enqueue' );
// v1.5 with help from https://developer.wordpress.org/plugins/shortcodes/shortcodes-with-parameters/
function getSimplePullQuote( $atts, $content = null ) {
$output = '';
$pull_quote_atts = shortcode_atts( array(
//'quote' => 'My Quote',
'class' => 'right',
), $atts );
$content = wpautop(trim($content));
return '<div class="simplePullQuote ' . wp_kses_post( $pull_quote_atts[ 'class' ] ) . '">'. do_shortcode($content) .'</div>';
}
add_shortcode('pullquote', 'getSimplePullQuote');
// LEGACY CODE for Version < 0.2.4
function getQuote(){
global $post;
$my_custom_field = get_post_meta($post->ID, "quote", true);
/* Add CSS classes to the pull quote (a.k.a. Style the thing!) */
return '<div class="simplePullQuote">'.$my_custom_field.'</div>';
}
/* Allow us to add the pull quote using Wordpress shortcode, "[quote]" */
add_shortcode('quote', 'getQuote');
function getQuote1(){
global $post;
$my_custom_field = get_post_meta($post->ID, "quote1", true);
/* Add CSS classes to the pull quote (a.k.a. Style the thing!) */
return '<div class="simplePullQuote">'.$my_custom_field.'</div>';
}
/* Allow us to add the pull quote using Wordpress shortcode, "[quote]" */
add_shortcode('quote1', 'getQuote1');
function getQuote2(){
global $post;
$my_custom_field = get_post_meta($post->ID, "quote2", true);
/* Add CSS classes to the pull quote (a.k.a. Style the thing!) */
return '<div class="simplePullQuote">'.$my_custom_field.'</div>';
}
// Allow us to add the pull quote using Wordpress shortcode, "[quote]" */
add_shortcode('quote2', 'getQuote2');