Skip to content

Commit

Permalink
changes for 0.8.5 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian Taggart committed Mar 24, 2015
1 parent 47554a0 commit 7699c4f
Show file tree
Hide file tree
Showing 10 changed files with 319 additions and 260 deletions.
9 changes: 8 additions & 1 deletion README.md
Expand Up @@ -10,6 +10,13 @@ Provides a library of additional template tags, 3rd-party libraries, and functio

# Changelog:

## 0.8.5
- PHP notice fix in wp_login_img()
- Refactored most calls to the PHP function extract() to improve debugging and readability
- Added filters for all mapi_featured_img() defaults
- Improved mapi_data_uri() fn
- Fixes for non-standard WP installs, mod_userdir URIs, and mThumb

## 0.8.4
- PHP notice fix for mapi_browser_from_ua()
- Added optional filter to add custom post type to "Right Now" box
Expand Down Expand Up @@ -47,7 +54,7 @@ Provides a library of additional template tags, 3rd-party libraries, and functio
## 0.8
Preparation for version 1.0 launch:
- Remove credits tab
- minify JS files
- Minify JS files
- Fix favicon scaling
- Added new Twitter API Tweets function, mapi_tweets_oauth
- Added mapi_excerpt_more_text filter
Expand Down
3 changes: 1 addition & 2 deletions controllers/mapi-options-init.php
Expand Up @@ -385,8 +385,7 @@ public function login_headerurl() {
}

public function login_head() {
$img_url = parse_url($this->options['custom_branding']['wp_login_img']['src']);
// echo '<pre>'; var_dump($img_url); echo '</pre>'; die;
$img_url = parse_url(@$this->options['custom_branding']['wp_login_img']['src']);

if(!empty($img_url['path'])) {
$image = mapi_thumb(
Expand Down
66 changes: 31 additions & 35 deletions core/mapi-attachment.php
Expand Up @@ -11,7 +11,7 @@
*
*/

require_once(MAPI_DIR_PATH . 'lib/BFI_Thumb.php');
require_once(MAPI_DIR_PATH.'lib/BFI_Thumb.php');

/**
*
Expand All @@ -31,33 +31,32 @@
function mapi_featured_img($args = array()) {

$defaults = array(
'w' => get_option('large_size_w', '1170'),
'h' => get_option('large_size_h', '1170'),
'id' => get_the_ID(),
'echo' => TRUE,
'alt' => mapi_get_attachment_image_title(),
'title' => mapi_get_attachment_image_title(),
'w' => apply_filters('mapi_featured_img_w', get_option('large_size_w', '1170')),
'h' => apply_filters('mapi_featured_img_h', get_option('large_size_h', '1170')),
'id' => apply_filters('mapi_featured_img_id', get_the_ID()),
'echo' => apply_filters('mapi_featured_img_echo', TRUE),
'alt' => apply_filters('mapi_featured_img_alt', mapi_get_attachment_image_title()),
'title' => apply_filters('mapi_featured_img_title', mapi_get_attachment_image_title()),
);
$args = wp_parse_args($args, $defaults);
extract($args, EXTR_SKIP);

if(has_post_thumbnail($id)) {
$featured_img = wp_get_attachment_image_src(mapi_get_attachment_id($id), 'full');
$src = $featured_img[0];
$img = mapi_thumb(array('src' => $src, 'w' => $w, 'h' => $h, 'id' => $id));
if($echo === TRUE) {
if(has_post_thumbnail($args['id'])) {
$featured_img = wp_get_attachment_image_src(mapi_get_attachment_id($args['id']), 'full');
$args['src'] = $featured_img[0];
$args['img'] = mapi_thumb(array('src' => $args['src'], 'w' => $args['w'], 'h' => $args['h'], 'id' => $args['id']));
if($args['echo'] === TRUE) {
echo apply_filters('mapi_featured_image_before', '<div class="mapi-featured-img">');
?>
<img alt="<?php echo $alt; ?>" <?php if($title) : echo 'title="' . $title . '"'; endif; ?> src="<?php echo $img; ?>" />
<img alt="<?php echo $args['alt']; ?>" <?php if($args['title']) : echo 'title="'.$args['title'].'"'; endif; ?> src="<?php echo $args['img']; ?>" />
<?php
echo apply_filters('mapi_featured_image_after', '</div>');
} else {
$image = array(
'w' => $w,
'h' => $h,
'src' => $img,
'alt' => $alt,
'title' => $title,
'w' => $args['w'],
'h' => $args['h'],
'src' => $args['img'],
'alt' => $args['alt'],
'title' => $args['title'],
);

return apply_filters('mapi_featured_image', $image);
Expand All @@ -79,7 +78,7 @@ function mapi_featured_img($args = array()) {
function mapi_featured_img_with_caption($args = array()) {
echo mapi_featured_img($args);
if(mapi_get_attachment_image_caption()) {
echo apply_filters('mapi_featured_img_caption', '<div class="caption">' . mapi_get_attachment_image_caption() . '</div>');
echo apply_filters('mapi_featured_img_caption', '<div class="caption">'.mapi_get_attachment_image_caption().'</div>');
}
}

Expand Down Expand Up @@ -360,12 +359,11 @@ function mapi_thumb_array($args) {
'ct' => apply_filters('mapi_thumb_ct', 1) // canvas transparency (overrides cc) 1 or 0
);
$args = wp_parse_args($args, $defaults);
extract($args, EXTR_SKIP);

if(empty($src)) {
if(empty($args['src'])) {
return mapi_error(array('msg' => 'Parameter "src" cannot be empty', 'echo' => FALSE, 'die' => FALSE));
} else {
$img_src = plugins_url('lib/mthumb.php', dirname(__FILE__)) . '?src=' . $src . '&amp;w=' . $w . '&amp;h=' . $h . '&amp;q=' . $q . '&amp;a=' . $a . '&amp;zc=' . $zc . '&amp;f=' . $f . '&amp;s=' . $s . '&amp;cc=' . $cc . '&amp;ct=' . $ct;
$img_src = plugins_url('lib/mthumb.php', dirname(__FILE__)).'?src='.$args['src'].'&amp;w='.$args['w'].'&amp;h='.$args['h'].'&amp;q='.$args['q'].'&amp;a='.$args['a'].'&amp;zc='.$args['zc'].'&amp;f='.$args['f'].'&amp;s='.$args['s'].'&amp;cc='.$args['cc'].'&amp;ct='.$args['ct'];

return apply_filters('mapi_thumb', $img_src);
}
Expand Down Expand Up @@ -411,7 +409,6 @@ function mapi_image($src = '', $args = array(), $single = TRUE) {
'crop_height' => apply_filters('mapi_thumb_crop_height', FALSE),
);
$args = wp_parse_args($args, $defaults);
extract($args, EXTR_SKIP);

$src = apply_filters('mapi_thumb_src', $src);

Expand Down Expand Up @@ -457,18 +454,17 @@ function mapi_random_img($args) {
'path' => apply_filters('mapi_random_image_path', $upload_dir['path']),
'height' => apply_filters('mapi_random_image_height', get_option('large_size_h')),
'width' => apply_filters('mapi_random_image_width', get_option('large_size_w')),
'alt' => apply_filters('mapi_random_image_alt', get_bloginfo('name') . ' - ' . get_bloginfo('description')),
'alt' => apply_filters('mapi_random_image_alt', get_bloginfo('name').' - '.get_bloginfo('description')),
'echo' => TRUE
);
$args = wp_parse_args($args, $defaults);
extract($args, EXTR_SKIP);

$src = plugins_url('core/mapi-random.img.php', dirname(__FILE__)) . '?dir=' . $dir . '&amp;path=' . $path;
$src = plugins_url('core/mapi-random.img.php', dirname(__FILE__)).'?dir='.$args['dir'].'&amp;path='.$args['path'];

if($echo) {
if($args['echo']) {
do_action('mapi_random_image_before');
?>
<img class="mapi-random-img" src="<?php echo $src ?>" width="<?php echo $width ?>" height="<?php echo $height ?>" alt="<?php echo $alt ?>" title="<?php echo $alt ?>" />
<img class="mapi-random-img" src="<?php echo $src ?>" width="<?php echo $args['width'] ?>" height="<?php echo $args['height'] ?>" alt="<?php echo $args['alt'] ?>" title="<?php echo $args['alt'] ?>" />
<?php
do_action('mapi_random_image_after');
} else {
Expand Down Expand Up @@ -498,19 +494,19 @@ function mapi_remove_large_image($image_data) {
// paths to the uploaded image and the large image

$sub_dir_array = explode('/', $image_data['file']);
$sub_dir = $sub_dir_array[0] . '/' . $sub_dir_array[1]; // eg. 2014/03
$sub_dir = $sub_dir_array[0].'/'.$sub_dir_array[1]; // eg. 2014/03

$uploaded_image_location = $upload_dir['basedir'] . '/' . $image_data['file'];
$large_image_location = $upload_dir['basedir'] . '/' . $sub_dir . '/' . $image_data['sizes']['large']['file'];
$uploaded_image_location = $upload_dir['basedir'].'/'.$image_data['file'];
$large_image_location = $upload_dir['basedir'].'/'.$sub_dir.'/'.$image_data['sizes']['large']['file'];
// no year/month folders
} else {
// paths to the uploaded image and the large image
$uploaded_image_location = $upload_dir['basedir'] . '/' . $image_data['file'];
$large_image_location = $upload_dir['path'] . '/' . $image_data['sizes']['large']['file'];
$uploaded_image_location = $upload_dir['basedir'].'/'.$image_data['file'];
$large_image_location = $upload_dir['path'].'/'.$image_data['sizes']['large']['file'];
}

// delete the uploaded image
unlink($uploaded_image_location); // @todo - this need to be tested again
unlink($uploaded_image_location);

// rename the large image
rename($large_image_location, $uploaded_image_location);
Expand Down
21 changes: 10 additions & 11 deletions core/mapi-page-post.php
Expand Up @@ -272,37 +272,36 @@ function mapi_list_posts_array($args) {
'slug' => NULL
);
$args = wp_parse_args($args, $defaults);
extract($args, EXTR_SKIP);

if($type == 'page') {
if($args['type'] == 'page') {
// get a single page by its slug
if(!isset($slug)) {
if(!isset($args['slug'])) {
mapi_error(array('msg' => 'no page slug was defined'));
} else {
$posts = get_posts("post_type=" . $type . "&name=" . $slug);
$posts = get_posts("post_type=" . $args['type'] . "&name=" . $args['slug']);
}
} else {
$posts = get_posts("post_type=" . $type . "&numberposts=" . $num . "&cat=" . $cat);
$posts = get_posts("post_type=" . $args['type'] . "&numberposts=" . $args['num'] . "&cat=" . $args['cat']);
}
$str = '<ul class="mapi list-posts">';
foreach($posts as $post) {
$str .= '<li><span class="link"><a href="' . get_permalink($post->ID) . '" title="' . $post->post_title . '">' . $post->post_title . '</a></span>';
if($show_excerpt) {
if($content_or_excerpt == 'excerpt') {
if($args['show_excerpt']) {
if($args['content_or_excerpt'] == 'excerpt') {
$str .= '<span class="excerpt">' . mapi_excerpt($excerpt_length, $post->ID) . '</span>';
}
if($content_or_excerpt == 'content') {
if($args['content_or_excerpt'] == 'content') {
$content = apply_filters('the_content', $post->post_content);
$content = str_replace(']]>', ']]&gt;', $content);
$str .= '<span class="excerpt">' . $content . '</span>';
}
}
if($show_more_link) {
$str .= '<span class="more">' . $more_before . '<a class="more" href="' . get_permalink($post->ID) . '" title="' . the_title_attribute(array('echo' => 0)) . '">' . $more_text . '</a>' . $more_after . '</span>';
if($args['show_more_link']) {
$str .= '<span class="more">' . $args['more_before'] . '<a class="more" href="' . get_permalink($post->ID) . '" title="' . the_title_attribute(array('echo' => 0)) . '">' . $args['more_text'] . '</a>' . $args['more_after'] . '</span>';
}
}
$str .= '</li></ul>';
if($echo) {
if($args['echo']) {
echo $str;
} else {
return $str;
Expand Down

0 comments on commit 7699c4f

Please sign in to comment.