Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all 8245 articles
Browse latest View live

alemieux on "WP Admin Slider Control"

$
0
0

Since this is in the admin, it's not going to be easy to share, but we have a slider control on our home page. In the admin area, we can add as many items as we want to the slider and include things like the logo, a description and a link. It's the link part that is broken. Instead of presenting a text field to input the proper link, it instead just displays the link and doesn't allow you to edit it.

These are in metaboxes that are included in the metaboxes.php file. This is the code for that section:

$home_metaboxes = array(
	/***===================================================================
			slideshow
		======================================================================= ***/
	'slideshow' => array(
		'title' => 'Homepage slideshow',
		'fields' => array(
			'slides' => array(
				'title' => 'Slides',
				'type' => 'group',
				'subfields' => array(
					'image' => array(
						'title' => 'Slide Background',
						'type' => 'media',
						'image_size' => 'large',
						'get' => 'image'
					),
					'image_align' => array(
						'title' => 'Image Alignment',
						'type' => 'select',
						'default' => 'middle',
						'options' => array(
							'top' => 'Top',
							'middle' => 'Middle',
							'bottom' => 'Bottom'
						)
					),
					'text' => array(
						'title' => 'Slide Text',
						'type' => 'textarea'
					),
					'link_text' => array(
						'title' => 'Link Text'
					),
					'link' => array(
						'title' => 'Link to:',
						'type' => 'post',
						// 'type' => 'textarea',
						'get' => 'url'
					)
				)
			)
		)
	),

The 'link' section is the problem. I've commented out the code I added to fix the issue: // 'type' => 'textarea' The default code is 'get' => 'url'.

If I set this to 'type' => 'textarea', it fixes the issue on the admin page, but causes an error to appear on the homepage pointing to this line of code in a separate file called post.php in a folder called Cloud_Options:

public static function get_option( $post_id, $spec ){
		if ( is_string( $spec ) ){

			$prop_to_get = $spec ;
		} else {
			$prop_to_get = self::property_to_get( $spec['get'] );
		}
		$value = '' ;
		switch ( $prop_to_get ){
			case 'ID' :
				return $post_id ;
				break;
			case 'post' :
				$value = get_post( $post_id ) ;
				break;
			case 'post_title' :
				$post = get_post( $post_id ) ;
				return $post->post_title ;
				break;
			case 'post_content' :
				$post = get_post( $post_id ) ;
				return apply_filters( 'the_content', $post->post_content ) ;
				break;
			case 'post_excerpt' :
				$post = get_post( $post_id ) ;
				return apply_filters( 'the_excerpt', $post->post_excerpt ) ;
				break;
			case 'post_thumbnail' :
				$image_size = isset( $spec['image_size'] ) ? $spec['image_size'] : 'full' ;
				return get_the_post_thumbnail( $post_id, 'thumbnail'  ) ;
				break;
			case 'post_thumbnail_id' :
				$attachment_id = get_post_thumbnail_id( $post_id ) ;
				return $attachment_id ;
				break;
			case 'post_thumbnail_url' :
				$attachment_id = get_post_thumbnail_id( $post_id ) ;
				$image_size = isset( $spec['image_size'] ) ? $spec['image_size'] : 'full' ;
				$image_info = wp_get_attachment_image_src( $attachment_id, $image_size ) ;
				return $image_info[0] ;
				break;
			case 'url' :
				return get_permalink( $post_id );
				break ;
		}
	}

It's in the first else statement. $prop_to_get = self::property_to_get( $spec['get'] ); Which I think is strange. I'm not sure how the two items are related.

Any insight would be appreciated.


Tiago on "Menu on responsive layout"

$
0
0

Hi everybody,

I have this website (http://www.officialzypher.com) and I love the way the menu behaves on the mobile version.
Then, I have this other website (http://www.edmsavedmylife.net), but I simply hate how the menu behaves on the mobile version.

Is there a way that someone here can help me with this, so I can have the menu on my second website behaving and looking like the one on the first website?

CSS for the first website (the one I like):

[Excessive CSS moderated. Please don't post an entire theme's stylesheet here.]

Thanks in advance!
Tiago

alemieux on "Slider Autoplay"

$
0
0

We have 2 videos on our careers page (http://www.affinnova.com/careers) that are included in a slider. The slider is based off of glide.js - which I'm not too familiar with.

The problem is that when the page loads, there is an animation that slides between the 2 videos. If you start playing a video, it will slide to the next when while it's playing. I'm trying to figure out which part of the code I need to address to prevent this behavior. Here's the code:

(function (f, e, b, h) {
    var d = "glide",
        g = {
            autoplay: 4000,
            animationTime: 500,
            arrows: true,
            arrowsWrapperClass: "slider-arrows",
            arrowMainClass: "slider-arrow",
            arrowRightClass: "slider-arrow--right",
            arrowRightText: "next",
            arrowLeftClass: "slider-arrow--left",
            arrowLeftText: "prev",
            nav: true,
            navCenter: true,
            navClass: "slider-nav",
            navItemClass: "slider-nav__item",
            navCurrentItemClass: "slider-nav__item--current",
            touchDistance: 60
        };

    function a(k, j) {
        var i = this;
        i.options = f.extend({}, g, j);
        i.parent = k;
        i.wrapper = i.parent.children();
        i.slides = i.wrapper.children();
        i.currentSlide = 0;
        i.CSS3support = true;
        i.init();
        i.build();
        i.play();
        if (i.options.touchDistance) {
            i.swipe()
        }
        f(b).on("keyup", function (l) {
            if (l.keyCode === 39) {
                i.slide(1)
            }
            if (l.keyCode === 37) {
                i.slide(-1)
            }
        });
        i.parent.add(i.arrows).add(i.nav).on("mouseover mouseout", function (l) {
            i.pause();
            if (l.type === "mouseout") {
                i.play()
            }
        });
        f(e).on("resize", function () {
            i.init();
            i.slide(0)
        });
        return {
            current: function () {
                return -(i.currentSlide) + 1
            },
            play: function () {
                i.play()
            },
            pause: function () {
                i.pause()
            },
            next: function (l) {
                i.slide(1, false, l)
            },
            prev: function (l) {
                i.slide(-1, false, l)
            },
            jump: function (m, l) {
                i.slide(m - 1, true, l)
            },
            nav: function (l) {
                if (i.navWrapper) {
                    i.navWrapper.remove()
                }
                i.options.nav = (l) ? l : i.options.nav;
                i.navigation()
            },
            arrows: function (l) {
                if (i.arrowsWrapper) {
                    i.arrowsWrapper.remove()
                }
                i.options.arrows = (l) ? l : i.options.arrows;
                i.arrows()
            }
        }
    }
    a.prototype.build = function () {
        var i = this;
        if (i.options.arrows) {
            i.arrows()
        }
        if (i.options.nav) {
            i.navigation()
        }
    };
    a.prototype.navigation = function () {
        var j = this;
        if (j.slides.length > 1) {
            var q = j.options,
                n = (j.options.nav === true) ? j.parent : j.options.nav;
            j.navWrapper = f("<div />", {
                "class": q.navClass
            }).appendTo(n);
            var p = j.navWrapper,
                l;
            for (var k = 0; k < j.slides.length; k++) {
                l = f("<a />", {
                    href: "#",
                    "class": q.navItemClass,
                    "data-distance": k
                }).appendTo(p);
                p[k + 1] = l
            }
            var m = p.children();
            m.eq(0).addClass(q.navCurrentItemClass);
            if (q.navCenter) {
                p.css({
                    left: "50%",
                    width: m.outerWidth(true) * m.length,
                    "margin-left": -p.outerWidth(true) / 2
                })
            }
            m.on("click touchstart", function (i) {
                i.preventDefault();
                j.slide(f(this).data("distance"), true)
            })
        }
    };
    a.prototype.arrows = function () {
        var j = this;
        if (j.slides.length > 1) {
            var l = j.options,
                k = (j.options.arrows === true) ? j.parent : j.options.arrows;
            j.arrowsWrapper = f("<div />", {
                "class": l.arrowsWrapperClass
            }).appendTo(k);
            var i = j.arrowsWrapper;
            i.right = f("<a />", {
                href: "#",
                "class": l.arrowMainClass + " " + l.arrowRightClass,
                "data-distance": "1",
                html: l.arrowRightText
            }).appendTo(i);
            i.left = f("<a />", {
                href: "#",
                "class": l.arrowMainClass + " " + l.arrowLeftClass,
                "data-distance": "-1",
                html: l.arrowLeftText
            }).appendTo(i);
            i.children().on("click touchstart", function (m) {
                m.preventDefault();
                j.slide(f(this).data("distance"), false)
            })
        }
    };
    a.prototype.slide = function (j, q, p) {
        var o = this,
            l = (q) ? 0 : o.currentSlide,
            m = -(o.slides.length - 1),
            n = o.options.navCurrentItemClass,
            i = o.slides.spread;
        o.pause();
        if (l === 0 && j === -1) {
            l = m
        } else {
            if (l === m && j === 1) {
                l = 0
            } else {
                l = l + (-j)
            }
        }
        var k = i * l + "px";
        if (o.CSS3support) {
            o.wrapper.css({
                "-webkit-transform": "translate3d(" + k + ", 0px, 0px)",
                "-moz-transform": "translate3d(" + k + ", 0px, 0px)",
                "-ms-transform": "translate3d(" + k + ", 0px, 0px)",
                "-o-transform": "translate3d(" + k + ", 0px, 0px)",
                transform: "translate3d(" + k + ", 0px, 0px)"
            })
        } else {
            o.wrapper.stop().animate({
                "margin-left": k
            }, o.options.animationTime)
        } if (o.options.nav) {
            o.navWrapper.children().eq(-l).addClass(n).siblings().removeClass(n)
        }
        o.currentSlide = l;
        if ((p !== "undefined") && (typeof p === "function")) {
            p()
        }
        o.play()
    };
    a.prototype.play = function () {
        var i = this;
        if (i.options.autoplay) {
            i.auto = setInterval(function () {
                i.slide(1, false)
            }, i.options.autoplay)
        }
    };
    a.prototype.pause = function () {
        if (this.options.autoplay) {
            this.auto = clearInterval(this.auto)
        }
    };
    a.prototype.swipe = function () {
        var u = this,
            q, o, k, j, r, p, v, w, l, s = 180 / Math.PI,
            t, i, n, m;
        u.parent.on("touchstart", function (x) {
            q = x.originalEvent.touches[0] || x.originalEvent.changedTouches[0];
            k = q.pageX;
            j = q.pageY
        });
        u.parent.on("touchmove", function (x) {
            q = x.originalEvent.touches[0] || x.originalEvent.changedTouches[0];
            r = q.pageX;
            p = q.pageY;
            t = r - k;
            i = p - j;
            n = Math.abs(t << 2);
            m = Math.abs(i << 2);
            v = Math.sqrt(n + m);
            w = Math.sqrt(m);
            l = Math.asin(w / v);
            if ((l * s) < 32) {
                x.preventDefault()
            }
        });
        u.parent.on("touchend", function (x) {
            q = x.originalEvent.touches[0] || x.originalEvent.changedTouches[0];
            o = q.pageX - k;
            if (o > u.options.touchDistance) {
                u.slide(-1)
            } else {
                if (o < -u.options.touchDistance) {
                    u.slide(1)
                }
            }
        })
    };
    a.prototype.init = function () {
        var i = this,
            j = i.parent.width();
        i.slides.spread = j;
        i.wrapper.width(j * i.slides.length);
        i.slides.width(i.slides.spread);
        if (!c("transition") || !c("transform")) {
            i.CSS3support = false
        }
    };

    function c(o) {
        var j = false,
            l = "Khtml Ms O Moz Webkit".split(" "),
            n = b.createElement("div"),
            m = null;
        o = o.toLowerCase();
        if (n.style[o]) {
            j = true
        }
        if (j === false) {
            m = o.charAt(0).toUpperCase() + o.substr(1);
            for (var k = 0; k < l.length; k++) {
                if (n.style[l[k] + m] !== h) {
                    j = true;
                    break
                }
            }
        }
        return j
    }
    f.fn[d] = function (i) {
        return this.each(function () {
            if (!f.data(this, "api_" + d)) {
                f.data(this, "api_" + d, new a(f(this), i))
            }
        })
    }
})(jQuery, window, document);

I already tried setting autoplay to false, which would seem to make sense, but that seems to turn playback off on the second video. In fact, the video playback controls seem to be hijacked by this script once you start playing a video.

Any help would be appreciated.

johnsimpson_uk on "Custom Posts with additional features"

$
0
0

Hi all,

I have a problem which I am unsure how to resolve....

I am doing a project for a client at the moment where I will be creating a custom post page which will hold a load of services that the customer offers, for each service I will be adding a load of new meta boxes in my custom post (code side) so it will be nice and easy for my client to add in the relevant content.

However there is a part needed where they want a table on the page, this table will need new rows adding but we do not know how many, so I need them to be able to click a "New Row" button and then add in the relevant content.... Each row will have a date set (a from date and a to date, not automatically set) - The next issue is I only want them to be able to delete or modify any of the rows which are in the date range, so for example if they created a row with a date range of nov-2011 - nov-2013 this date would have passed so they should not be able to delete this entry... archiving the past entries if you like.

is this at all possible? can you point me in the right direction? I don't really want to use a plugin I would rather code it if possible.

many thanks in advance, if you need any more details please let me know.

markusday on "Make content of a 'shortcode' translatable through php _e function"

$
0
0

How do I make the content produced by this shortcode translatable with WPML?

<div id="CSpart2"><?php echo do_shortcode('[RICH_REVIEWS_SHOW num="all"]');?></div>

Rayandrade on "Change Pagination link"

$
0
0

Hi, I'm still looking for a solution for this:

My blog is already paged, but the only problem is that the pages navigation links url calls blog/page/2 and i need the link to be blog/2.

If I Type http://www.mysite.com/blog/2 i can see the second page working perfectly, but the links for next and previous pages add automatically the "/page" to the url. How can I fix it? Is there something to do with database?

Thanks,
Ray

hanbr on "Modify post meta before inserting new post"

$
0
0

Hi!

I'm trying to modify the post meta before inserting a new post. I can't finda anyway to do this. The closest I get is the wp_insert_post_data filter, but there I think I can only modify the $data array and not the $postarr array where the post meta are located:

add_filter( 'wp_insert_post_data' , 'modify_post_meta_before_insert' , '99', 2 );
function modify_post_meta_before_insert( $data , $postarr )
{
if($data['post_type'] == 'special_post_type') {
// Here I would like to modify $postarr
// $postarr['post_meta_type'] = ...
}
return $data; // Here I can only return $data and not $postarr ?
}

gowrann on "Stripping Inline Width Style for wp_caption on Images"

$
0
0

Wordpress adds a width attribute inline style for an image when a caption is used resulting in mark similar to :
<div id="attachment_5" class="wp-caption alignnone" style="width: 280px">

I want to globally strip these from my site and found a function on a few web sites:

add_shortcode('wp_caption', 'fixed_img_caption_shortcode');
add_shortcode('caption', 'fixed_img_caption_shortcode');
function fixed_img_caption_shortcode($attr, $content = null) {
	if ( ! isset( $attr['caption'] ) ) {
		if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) {
			$content = $matches[1];
			$attr['caption'] = trim( $matches[2] );
		}
	}
	$output = apply_filters('img_caption_shortcode', '', $attr, $content);
	if ( $output != '' )
		return $output;
	extract(shortcode_atts(array(
		'id'	=> '',
		'align'	=> 'alignnone',
		'width'	=> '',
		'caption' => ''
	), $attr));
	if ( 1 > (int) $width || empty($caption) )
		return $content;
	if ( $id ) $id = 'id="' . esc_attr($id) . '" ';
	return '<div ' . $id . 'class="wp-caption ' . esc_attr($align) . '" style="width: ' . $width . 'px">'
	. do_shortcode( $content ) . '<p class="wp-caption-text">' . $caption . '</p></div>';
}

Problem is that the code doesn't seem to work in 3.5.1 I believe it only works up to 3.4. Can anyone contribute to how it can be tweaked to work in the latest version?

THanks


Twansparant on "Automatically add anchor links as children elements in custom nav walker"

$
0
0

Hi there,

I'm struggling with a problem I can't seem to figure out myself...
What I want is to automatically add anchor links from a loop in the parent page as a dropdown submenu with a custom navigation walker.

I use Advanced Custom Fields to add extra content blocks in a page, in each block there is a named anchor that should be added to the parent page as a submenu.

What I got so far: pastebin.com/YbY1wxSa

The normal output of the $children_elements would be like this:

Array (
    [7] => Array (
            [0] => WP_Post Object (
                [ID] => 124
                etc ...
                [current_item_parent] =>
            )
            [1] => WP_Post Object (
                [ID] => 125
                etc ...
                [current_item_parent] =>
            )
            [2] => WP_Post Object (
                [ID] => 126
                etc ...
                [current_item_parent] =>
            )
        )
)

But my output of the $children_elements is like this:

Array (
    [7] => Array (
            [0] => Array (
                [ID] => 124
                etc ...
                [current_item_parent] =>
            )
            [1] => Array (
                [ID] => 125
                etc ...
                [current_item_parent] =>
            )
            [2] => Array (
                [ID] => 126
                etc ...
                [current_item_parent] =>
            )
        )
)

So the children elements are in an Array and not in a WP_Post Object.
What do I need to change in order to add the anchors correctly without needing to create new nav_menu_item in the database?

Any help is welcome!
Thanks

luigidt on "Jigoshop wrapping help"

$
0
0

dear all

i'm trying to wrap jigoshop with my theme with no luck
please help

<?php
/**
* The main template file. Includes the loop.
*
*
* @package Customizr
* @since Customizr 1.0
*/
?>
<?php do_action( '__before_main_wrapper' ); ##hook of the header with get_header ?>
<div id="main-wrapper" class="<?php echo tc__f( 'tc_main_wrapper_classes' , 'container' ) ?>">

<?php do_action( '__before_main_container' ); ##hook of the featured page (priority 10) and breadcrumb (priority 20)...and whatever you need! ?>

<div class="container" role="main">
<div class="row">

<?php do_action( '__before_article_container'); ##hook of left sidebar?>

<div id="content" class="<?php echo tc__f( '__screen_layout' , tc__f ( '__ID' ) , 'class' ) ?> article-container">

<?php do_action ('__before_loop');##hooks the header of the list of post : archive, search... ?>

<?php if ( tc__f('__is_no_results') || is_404() ) : ##no search results or 404 cases ?>

<article <?php tc__f('__article_selectors') ?>>
<?php do_action( '__loop' ); ?>
</article>

<?php endif; ?>

<?php if ( have_posts() && !is_404() ) : ?>
<?php while ( have_posts() ) : ##all other cases for single and lists: post, custom post type, page, archives, search, 404 ?>
<?php the_post(); ?>

<?php do_action ('__before_article') ?>
<article <?php tc__f('__article_selectors') ?>>
<?php do_action( '__loop' ); ?>
</article>
<?php do_action ('__after_article') ?>

<?php endwhile; ?>

<?php endif; ##end if have posts ?>

<?php do_action ('__after_loop');##hook of the comments and the posts navigation with priorities 10 and 20 ?>

</div><!--.article-container -->

<?php do_action( '__after_article_container'); ##hook of left sidebar ?>

</div><!--.row -->
</div><!-- .container role: main -->

<?php do_action( '__after_main_container' ); ?>

</div><!--#main-wrapper"-->

<?php do_action( '__after_main_wrapper' );##hook of the footer with get_get_footer ?>

powermaniac on "Issue with database insert comparing dual meta_keys"

$
0
0

Not sure if its the right area, but I'm stumped with what I have wrong in this wpdb query.

I have this:

$testresults = $wpdb->get_results(

"SELECT user_id
FROM {$wpdb->base_prefix}usermeta
WHERE (((meta_key = 'skill_role_name'
AND meta_value LIKE '%%%$search_terms%%')
OR (meta_key = 'description'
AND meta_value LIKE '%%%$search_terms%%'))
AND
(meta_key = 'zip'
AND meta_value IN (" . implode(',', array_map('intval', $zips_array)) . ")" . "))
"

);

I've echo'd this out as a test, and ran it in the database through MySQL, but it doesn't seem to like it. This is meant to grab where ('skill_role_name' OR 'description' = $search_terms) AND ('zip' = in($array)).

What I get when I echo it out is this:

SELECT user_id FROM wp_usermeta WHERE (((meta_key = 'skill_role_name' AND meta_value LIKE '%%%director%%') OR (meta_key = 'description' AND meta_value LIKE '%%%director%%')) AND (meta_key = 'zip' AND meta_value IN (90026,90057,90081,90084,90086,90051,90087,90088,90012,90017,90071,90030,90074,90099,90029,90039)))

Any ideas?

athpirs on "Add Custom Post Type To Recent Post Wdget"

$
0
0

Hello everyone,
I have a site with a CPT and I want that to show up in the default recent post widget along with my original post type content.

How do I conquer this issue?

Thank you in advance!

Lugaru on "Woocommerce add Custon data to Order item meta"

$
0
0

Hey,

im relativley new to WordPress. I have the following Situation/Problem:

Wordpress installation with The Event Calender Plugin, Woocommerce and Wootickets.

Now I need to store some custom Data to the Order Item Meta and I dont know how. The User has the Option to Click two buttons (same Product). Variable Products are not an Option.

On one button no additional Data will be saved, on the second one i want to store a kind of unique id... I already have it in the post fields, but how to save it anywhere in the database, belonging to the Order and the Product?

EDIT: A second question just came up: I limited the quantity to 1 per Product. So a order only can contain 1 piece of each product, but I want to deny a "rebuy", so if the user comes back he shold not be allowed to purchase the same Product again...

Thanks in advance

Cheers

bacanzito on "spoiler popup to affiliate users with adf.ly"

jimii on "Want to hide-unset media-menu & set featured img tab on upload mgr"

$
0
0

I need some help to try and hide or unset the .media-menu element and to style the .media-frame-content (left side panel of media upload mgr). I'd also like to hide the set featured image meta link... ideally hiding both of these from anyone that is not an admin (update core)

I've tried a small plugin and child theme colors css file to the point of exhaustion...

Is there a simple function edit that I can put in my child function file that will hide the tab and set featured image meta link?

I user twenty ten with wp property. Thank you for any guidance.


johnboy01 on "Short URI ?"

$
0
0

Hi,

Creating my first wordpress site, and im used to my file directory being
/root
-page files
-/img
-/css
-/js
Is there anyway to cut out wp-content/themes/yadadada its especially worse in the html with "http://www.domain.com/yadadadadadadadada"

bluep92877 on "What filter would I use to alter custom field data just before saving?"

$
0
0

I have a custom post type I've created that has custom fields attributed to it.

I'm trying to use the wp_insert_post_data filter to modify form values.

http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_insert_post_data

To help with debugging, I've done a data dump of the $data and $postarr in the callback.

Whenever I click "add new" I can see the values that have been setup. These array values however do not include any of the custom fields. When I click edit on an existing field, this hook doesn't fire. Should it not since the codex says 'when updating a post' in addition to saving it for the first time?

How do I access my custom fields as well as other fields such as the Featured Image field? Am I using the correct filter, and if not, which should I use?

hannahhayes on "Removing year from archive list"

$
0
0

Hi there,

Is it possible to get the archives list to display the month only? For example, January as opposed to January 2014.

I'm trying to create an archives intro that is tabbed by year:

http://www.everly.co.uk/2009/12/

But I'm not very good with code outside out HTML and CSS and I can't figure it out!

Thanks.

elsnare on "Autom. create htacces file in /uploads/ for new month"

$
0
0

Introduction:
I'm using a plugin that allows users to upload files to the server, into the standard /wp-content/uploads/year/month/ folder. Event thou I'm using a security check @ upload to disallow spec. file types, I would like to add another layer of secuiriy.

What do I want to do:
Write a script that will automatically place a htaccess file at the beginning of each month into the corresponding upload folder. The file will contain rules to prevent script execution, even if a file slips through the 1st check.

Any ideas how to get started with this? :)

hawaiibillT on "navis jiffy post"

$
0
0

Hi all. I have been using a plugin navis-jiffy-posts that works good for me except I would like the oembed links it produces to open in a new window. This is what is in the js. I havent been able to get target="new" to work.
a href="' + oembed.url + '">' + domain + '/a>
Is there a way to do it or is the oembed keeping it from working?

navis-jiffy-post link

Hope you can help me.

Viewing all 8245 articles
Browse latest View live




Latest Images