This repository has been archived by the owner on Apr 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
readme.html
195 lines (181 loc) · 10.3 KB
/
readme.html
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http</strong>://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>A guide to the WordPress Theme Utilites</title>
<link rel="stylesheet" href="readme.css" type="text/css" media="screen" />
</head>
<body>
<h1>A guide to WordPress Theme Utilites</h1>
<p>Version <em>1.0</em></p>
<p>
<em>WordPress Theme Utilites</em> was written to take care of some of the numerous required plugins and hacks that tend to build up in template function files.
</p>
<p> This plugin was written by <a href="http://simondouglas.com">Simon Douglas</a> 2012 — 2013</p>
<h3 class="clear">Public</h3>
<ul>
<li class="space"><strong>wptu_get_attachment</strong>: gets everything you want for an image. <br />
For example:
<pre><code>$image_properties = wptu_get_attachment("post_id={$post_id}&attachment_id={$image_id}&size=thumbnail&alt={$title}&width={$width}&height={$height}");</code></pre>
<br />
Where <code>$post_id = $post->ID</code> and <code>$attachment_id is the id of the image</code><br />
The <code>$size</code> parameter will build up the <code>image_tag</code> value, you can just echo that out to your template. <br />
You will get a deep array of image properties thus:
<pre>
<code>
[post_id] => 262
[attachment_id] => 263
[link] => http://www.vancouverfoundationawards.ca/wp-content/uploads/2011/01/13/allison-b/SmallGrantProject.jpg
[source] => http://www.vancouverfoundationawards.ca/wp-content/uploads/2011/01/13/allison-b/SmallGrantProject-138x108.jpg
[width] => 138
[height] => 108
[image_size] => thumbnail
[meta_data] => Array
(
[width] => 4224
[height] => 3168
[hwstring_small] => height='96' width='128'
[file] => 2011/01/13/allison-b/SmallGrantProject.jpg
[sizes] => Array
(
[thumbnail] => Array
(
[file] => SmallGrantProject-138x108.jpg
[width] => 138
[height] => 108
)
[medium] => Array
(
[file] => SmallGrantProject-300x225.jpg
[width] => 300
[height] => 225
)
[large] => Array
(
[file] => SmallGrantProject-400x300.jpg
[width] => 400
[height] => 300
)
[news-image] => Array
(
[file] => SmallGrantProject-185x100.jpg
[width] => 185
[height] => 100
)
)
[image_meta] => Array
(
[aperture] => 2.9
[credit] =>
[camera] => COOLPIX P6000
[caption] =>
[created_timestamp] =>
[copyright] =>
[focal_length] => 6
[iso] => 64
[shutter_speed] => 0.00215238
[title] =>
)
)
[mime] => image/jpeg
[title] => SmallGrantProject
[caption] =>
[alt] => A green transformation
[description] =>
[date] => 2011-01-13 00:14:05
[image_tag] => <img src="http://www.vancouverfoundationawards.ca/wp-content/uploads/2011/01/13/allison-b/SmallGrantProject-138x108.jpg" width="138" height="108" alt="A green transformation"/>
[filename] => SmallGrantProject-138x108.jpg
[class] =>
</code>
</pre>
Therefore to get the camera used for example we could go <code>$image_properties['meta_data']['image_meta']['camera']</code> which would retrieve COOLPIX P6000. </li>
<li class="space"><strong>wptu_add_post_image</strong>: This attaches an image via a hook to the post. It is coupled with <em>wptu_get_attachment</em> as a means to add post images. Parameters must be added through the filter <em>wptu_add_post_image_args</em></li>
<li class="space"><strong>wptu_add_post_image_args: </strong>Filter used to add parameters to <em>wptu_add_post_image </em>function. </li>
<li><del><strong>wptu_get_cft_id</strong>: retrieves a value between known delimeters. Useful with the CFT plugin.</del></li>
<li><del><strong>wptu_get_cft_repeating_data</strong>: Used with the CFT in side of repeating field sets to get repeating data. Note: Repeating fields in the CFT plugin are useless, so use the <a href="http://magicfields.org/" target="_blank">Magic Fields Plugin</a> instead.</del></li>
<li><strong>wptu_get_the_browser</strong>: gets useful properties of the user browser. This is called automatically and added to the <code>body_class</code> hook. You probably shouldn't have to call it again as it can add considerable time to file execution.</li>
<li><strong>wptu_is_descedant</strong>: determines if a page is a child(n) of another.</li>
<li>$<strong>wptu_browser_classes</strong>: global registed that contains browser specific classes.</li>
</ul>
<h2>WPTU Admin Panel</h2>
<p><em>Added in version 1.0</em><br />
<strong>WordPress Menu → Settings → WordPress Theme Utilites</strong></p>
<p>This is a customisable panel that can be used to store data in the Options Table for your website.
<br />Data is stored as a serialised array so it can be access easily.<br /> Using <code>wptu_plugin_option('field_name')</code> will retrieve the value of the field for you.
</p>
<h5>General Settings</h5>
<ul>
<li>jQuery Version</li>
<li>Use Modernizer or not</li>
<li>Add body classes to the <code>body_class()</code> function</li>
<li>Add extra TinyMCE styles. This still works without TinyMCE Advanced</li>
<li>Google Analytics code for the header</li>
</ul>
<h5>Social Media</h5>
<p>Twitter, Facebook, YouTube, LinkedIn for your client site</p>
<h5>Adding Extra Settings</h5>
<p>Add <code>wptu-core-options.php</code> to your theme, then use the provided hooks to add more fields.</p>
<p>An example from <a href="http://woodworks.org">WoodWorks</a></p>
<pre>
<code>/*Adds A heading to the WordPress Theme Utilites Options Panel - take a look at wptu-settings.php for info...*/
function wptu_core_section_options(){
$args = array( 'woodworks' => 'Woodworks Custom Post Types' );
return $args;
}
/* Adds a field to the section woodworks */
function wptu_core_section_settings(){
$args = array('ww_staff_slug' => array(
'title'=>'Staff Archive Slug',
'desc'=>'This is for breadcrumb functionality. Define the with_front property of the slug',
'std'=>'',
'type'=>'text', // text,textarea,radio,select
'section'=>'woodworks' )
);
return $args;
}</code>
</pre>
<h2>Shortcodes</h2>
<ul>
<li>[bloginfo] Returns the shortcodes for bloginfo e.g. [bloginfo key="name"] returns the sitename. <br />
The WP <a href="http://codex.wordpress.org/Function_Reference/bloginfo" target="_blank">Codex has values</a>.</li>
<li>[admin_email] Returns the admin email in the format <a href="admin_email">bloginfo('name')</a>. No parameters.</li>
<li>[email] e.g. [email mailbox="simon" url="wptu.ca" subject="Enquiry From Site" display_text="display text!"]. <br />
This outputs literally:
<pre><code><script type="text/javascript">eE=('simon' + '%40' + 'wptu.ca?subject=Enquiry%20From%20Site');eD=('<span class="display-text">display text!</span>');document.write('<a href="&#109&#97&#105&#108&#116;&#111;&#58;' + eE + '">' + eD + '</a>');</script>
</code></pre>
</li>
<li>[include]. Does a simple php include. [include file="path_to_file"]. Put your includes in your template directory.</li>
<li>[loop]. This is a useful way to drop in post data into a page.<br />
<pre><code>[loop category='slug_name_or_id' query='anything_you_want_eg_orderby' pagination='true']</code></pre>
<em>Improved in 1.0.13</em>. Now accepts parameters such as taxonomy ( <code>tax="tax_name"</code> ), <code>term="term_name"</code> and <code>loop</code> template.
<pre>
// example from woodworks.org
<code>[loop query="posts_per_page=-1&post_type=resources&orderby=date&order=ASC" tax="resource_type" terms="information-sheets" loop="excerpt-information"]</code>
// result:
// Get all posts from the resource post type order by date ascending that have
// the term information-sheets ( like a tag )
// Output the data to template "loop-excerpt-information.php" which is responsible for formatting.
</pre>
<p>If wp_pagenavi is present, <code>pagination=true</code> will enable it.</p>
<p><em>Improvements in 1.1</em><br />
WP PageNavi has slightly changed so this plugin had to be updated. Compatible with WP PageNavi 2.83 <br />
Implementation is the same, but there could be bugs with <code>$paged</code>.
</p>
</li>
</ul>
<h2>Private</h2>
<p>This stuff all turns up for free.</p>
<ul>
<li>WPTU Developer Notes added to the dashboard so you can leave notes to you and other developers. Added ()</li>
<li>Added warning bar if you are viewing the site locally ( 0.9.8.2 )</li>
<li>Added <a href="http://www.modernizr.com/" target="_blank">Modinzer</a> support for html5 sites and detecting CSS3.</li>
<li>You can place your shortcodes in <strong>text widgets</strong> and they evalute.</li>
<li>Removing WordPress version and fluff in the <code>meta</code> header.</li>
<li>jQuery is added automatically from Google.</li>
<li>ID's are added to the Media browser, for your convenience. IDs are also added to all Admin tables.</li>
<li>ID's are added to the CMS Tree plugin if it is available ( usually is on most WPTU Sites )</li>
<li>Various Tinymce clean up filters which run to remove empty spaces and line breaks (the latter could be a problem depending on your setup.)</li>
</ul>
<p>2013 <a href="http://www.simondouglas.com" target="_blank">simondouglas.com</a>.</p>
</body>
</html>