-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
executable file
·78 lines (68 loc) · 3.18 KB
/
functions.php
File metadata and controls
executable file
·78 lines (68 loc) · 3.18 KB
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
<?php require_once('functions/base.php'); # Base theme functions
require_once('functions/feeds.php'); # Where functions related to feed data live
require_once('custom-post-types.php'); # Where per theme post types are defined
require_once('functions/admin.php'); # Admin/login functions
require_once('functions/config.php'); # Where per theme settings are registered
require_once('shortcodes.php'); # Per theme shortcodes
//Add theme-specific functions here.
/**
* Get a random post from the FrontPage post type
*
*
* @author Chris Conover
**/
function get_front_page_post() {
$front_page_posts = get_posts(array('numberposts'=>1,'orderby'=>'rand', 'post_type'=>'frontpage'));
$post_thumbnail_id = get_post_thumbnail_id($front_page_posts[0]->ID);
$featured_image = wp_get_attachment_image_src($post_thumbnail_id,'single-post-thumbnail');
return array(
'post' => $front_page_posts[0],
'featured_image' => $featured_image);
}
/**
* Truncates a string based on word count
*
* @return string
* @author Chris Conover
**/
function truncate($string, $word_count=30) {
$parts = explode(' ', $string, $word_count);
return implode(' ', array_slice($parts, 0, count($parts) - 1)).'...';
}
/**
* Change all gravity forms to submit to the page they are on
**/
function change_form_action($form_tag, $form) {
return preg_replace("/action='(.*?)'/", "action='.'", $form_tag);
}
add_filter('gform_form_tag', 'change_form_action', 10, 2);
/**
* Get the publication's Issuu ID based on the Wordpress embed code provided by Issuu
* @return string
**/
function get_publication_docid($pub_id) {
$embedcode_explode = preg_split("/documentId=/", get_post_meta($pub_id, 'publication_embed', TRUE)); //split up shortcode at documentid
$embedcode_explode = preg_split("/ name=/", $embedcode_explode[1]); //remove the rest of the embed code, leaving the document id
$docID = $embedcode_explode[0];
return $docID;
}
/**
* Get publication's thumbnail from Issuu based on the document ID found in the pub's embed shortcode:
* @return string
**/
function get_publication_thumb($pub_id) {
$docID = get_publication_docid($pub_id);
$pub = get_post($pub_id);
$thumb = "<img src='http://image.issuu.com/".$docID."/jpg/page_1_thumb_large.jpg' alt='".$pub->post_title."' title='".$pub->post_title."' />";
return $thumb;
}
/**
* Get publication's actual iframe embed code based on the document ID found in the pub's embed shortcode:
* @return string
**/
function get_publication_iframe($pub_id) {
$docID = get_publication_docid($pub_id);
$iframe = '<div><object style="width:100%;height:100%"><param name="movie" value="http://static.issuu.com/webembed/viewers/style1/v2/IssuuReader.swf?mode=mini&backgroundColor=%23222222&documentId='.$docID.'" /><param name="allowfullscreen" value="true"/><param name="menu" value="false"/><param name="wmode" value="transparent"/><embed src="http://static.issuu.com/webembed/viewers/style1/v2/IssuuReader.swf" type="application/x-shockwave-flash" allowfullscreen="true" menu="false" wmode="transparent" style="width:100%;height:100%" flashvars="mode=mini&backgroundColor=%23222222&documentId='.$docID.'" /></object></div>';
return $iframe;
}
?>