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

davidfcarr on "Not sure why I'm getting "This plugin is not properly prepared for localization""

$
0
0

How do I debug @WordPress #plugin repository msg "This plugin is not properly prepared for localization" for https://wordpress.org/plugins/rsvpmaker/

I've followed the internationalization guidelines, as far as I can tell, and a handful of translations have been produced for this code. But anyone seeing that message would think it's not worth trying.

What tripwire am I hitting?


c05338 on "Override Class of plugin in functions"

$
0
0

I've copied the class file from the plugin directory to the theme directory and then called it using require_once then added to the top of the class file class Extra_Class extends Main_Class Trying to override the full class function as a new one but it's not working.

venomphil on "Custom Query, Ajax Pagination and do_shortcode"

$
0
0

Hi WordPress Community,

So I have a Custom Query running with Ajax but cannot figure out how to get the do_shortcode to run.

The function is recognized, if you run it with no argument you get an 'expecting argument 1' error, the shortcode itself isn't recognized.

Template.php

<script>
				var newspage = 1;
				var $ = jQuery;
				function browsenews(x) {
					newspage = x;
					$.post('/newsloader', { derp: x}, function(result) {
						$('.newswrapper').html(result);
					});
				}
			</script>
			<!-- START news -->
			<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
			<div id="content" class="news">
				<div id="inner-content" class="wrap cf">
					<main id="main" class="m-all t-3of3 d-7of7 cf" role="main" itemscope itemprop="mainContentOfPage" itemtype="http://schema.org/Blog">
						<article id="post-<?php the_ID(); ?>" <?php post_class( 'cf' ); ?> role="article" itemscope itemtype="http://schema.org/BlogPosting">

							<header class="article-header">
								<h1 class="page-title">news</h1>
							</header>

							<section class="entry-content cf" itemprop="articleBody">
							<?php
							$newsArgs = array(
							'post_type' => 'post',
							'cat' => '3',
							'posts_per_page' => 1,
							'order' => 'ASC' );
							$philquery = new WP_Query($newsArgs);
							echo '<div id="news-posts"><div class="newswrapper">';
								while ($philquery->have_posts()) : $philquery->the_post();?>
									<li>
										<div class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
										<div class="content"><?php echo the_content(); ?></div>
										<div class="share"><?php echo do_shortcode('[addtoany]') ?></div>
										<div class='navigation'></div>
									</li>
								<?php endwhile; ?>
								<input value='Next' type='button' onclick='browsenews(2);'>
							</div>

							</div>
							</section>

						</article>
					</main>
				</div>
			</div>
			<?php endwhile; endif; ?>
			<!-- END news -->

newsloader.php

$derp = intval($_POST['derp']);
$newsArgs = array(
	'post_type' => 'post',
	'posts_per_page'=>1,
	'paged'=>$derp,
);
$philquery = new WP_Query($newsArgs);
$next = array(
	'post_type' => 'post',
	'posts_per_page'=>1,
	'paged'=>$derp+1,
);
$nextq = new WP_Query($next);
print_r(do_shortcode('[addtoany]'));
while ($philquery->have_posts()) : $philquery->the_post();?>
	<li>
		<div class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
		<div class="content"><?php the_content(); ?></div>
		<div class="share"><?php echo do_shortcode('[addtoany]') ?></div>
	</li>
<?php endwhile;
	if ($derp > 1) {
		echo "<input value='Back' type='button' onclick='browsenews(".($derp-1).");'>";
	}

	if ($nextq->found_posts > 0) {
		echo "<input value='Next' type='button' onclick='browsenews(".($derp+1).");'>";
	}

loauy24 on "Add like button to posts"

$
0
0

Hi everyone,

I want to know how to add like button on my posts.

The main idea is about create counter increased by one when someone clicked on like button.

I want to do this "programmatically" without use any plugin.

Can anybody help me? Thanks in advance

ritterml on "My custom metabox will not display"

$
0
0
<?php

namespace VertuAssignmentSystem;

// No direct access
if ( ! defined( 'ABSPATH' ) ) exit;

class Vertu_Assignment_System{

    public function __construct()
    {
        add_action('init',array($this,'assignment_post_type_init'));

        add_action('add_metaboxes',array($this,'description_metabox_add'));

        add_action('save_post', array($this,'description_metabox_save'));
    }

    /*
     * Custom Post Types
     */

    public function assignment_post_type_init(){
        $labels     =   array(
            'name'                  =>  __('Assignments'),
            'singular_name'         =>  __('Assignment'),
            'add_new_item'          =>  __('Add new Assignment')
        );
        $args       =   array(
            'labels'                =>  $labels,
            'description'           =>  __('Manage client project assignments for authors and editors.'),
            'rewrite'               =>  array( 'slug' => 'assignment' ),
            'public'                =>  true,
            'supports'              =>  array('editor')
        );
        register_post_type('vertu_assignment', $args);
    }

    /*
     * Metaboxes
     */

    public function description_metabox_add(){
        $post_types    = array('vertu_assignment','post');
        //if( in_array( $post_types, $post_type ) ){
        foreach ($post_types as $post_type){
            add_meta_box(
                'vertu_description_metabox',
                'Description',
                array($this,'description_metabox_field'),
                $post_type,
                'side',
                'default'
            );
        }
    }

    public function description_metabox_save( $post_id ){
        $field      =   'vertu_description_metabox';
        if( array_key_exists($field, $_POST) ){
            update_post_meta(
                $post_id,
                '_vertu_description',
                $_POST[$field]
            );
        }
    }

    public function description_metabox_field( $post ){
        $field      =   "vertu_description_metabox";
        $content    = get_post_meta( $post->ID,'_vertu_description',true );
        echo ('<label for="' . $field . '"> Description </label>');
        echo ('<textarea name="' . $field .'" id="' . $field . '">' . $content . '</textarea>');
    }
}

new Vertu_Assignment_System();

Regardless of attempts, I cannot get the metabox to display on any post type edit pages.

vlad.nitu on "Spam links in footer"

$
0
0

Hello guys!
Before saying it yes, I know I should not use this version of wordpress (3.4.2).
I have a client which does not want under no circumstance to update the core so I simply have to deal with it.
The point is that today or yesterday there appeared a few spam links under the footer of every page.
They all lead to turkish hacking forums, turkish massage salons etc.
The look like this:
hack forum r57shell c99 shell r57 Hacking masaj salonu

After a fast search on Google I found no advice yet I found a lot of websites that have this exact row of links in pages.

Could someone please help me remove it? Or at least instruct me with minimal ideas of where I should look or what I should look for.
I ran out of ideas. I tried header, footer, javascript, 404 page, a search through all files with these key words, a search in all files with these key words encoded in base 64, nothing!

boybawang on "Trying to understand SVN (trunk, tags, versioning)"

$
0
0

Hey all -

I created a plugin a couple of months ago, added to trunk, and all is well. I did not create a tag for that release, and currently the trunk's readme.txt says:

Stable tag: trunk

What I'd like to do now is tag my first release as 1.0, but I'm pretty confused. Suppose I make a copy of trunk, and put it in a folder named 1.0 within the 'tags' directory. The readme.txt stable tag still says 'trunk' in the 1.0 version (within the 'tags' directory).

Should I change this? Does it even matter? If somebody rolls back to this version, and the stable tag says 'trunk', will it detect that there's a new version that they need to update to?

Moving forward, would it be better for the readme.txt stable tag within trunk to point to the version within the tags directory, or should I keep it pointing to trunk?

SVN has me well-confused :(

Arturo emilio on "How to use wp_rewrite with static page?"

$
0
0

I'm working in a translation plugin for Wordpress however it seems impossible to fix the bug with the home with an static page.

If you add a parameter with query_vars and have an static home page, as soon as you use that new param the home url doesn't work and shows latest blog entries.
This bug is being around from forever, it hasn't being fixed yet.

In Wordpress 4.4 I could somehow "hack" my way in parsing the url to retrieve the parameter and delete the query variable.
However this doesn't work anymore in Wordpress 4.5. It redirects me to the homepage instead and delete the pretty url.
Or it redirect to the latest entries instead the static page if you keep the new param.

Is there any way to achieve what this?

Example: you add a new query_var foo with all the redirects.
When you access to
Mysite.com/foo -> it will show the latest entries instead the static webpage.


zzuum on "Array in shortcode function"

$
0
0

Hello,
I have one array. like this :

$test['1','2','3'];

and now I want to create shortcode that will return me that array. And that array i get outside of shortcode function.

$test['1','2','3'];

var_dump($arrt);
function movies_func($arrt) {
return 'test';
}
add_shortcode('movies', 'movies_func');

I need to push that array in shortcode fucntion and then return it, and show on page, with shortcode. Is there any way to do that? And i don't want to create my array in that function.

lucawater on "Import term content"

$
0
0

I created a couple of custom taxonomies. Each term has a couple of custom fields(created with Advanced Custom Fields). I am going to have a lot of terms(football teams), and I don't want to edit them all manually in the wordpress backend.

I know you can add terms with wp_insert_term. The thing is, I cannot add the custom fields to that function.

Is there some way where I can(preferably using csv files) import terms with those custom fields?

Thanks!

Christine Rondeau on "Add sharing option to jetpack subscriptions"

$
0
0

I'm using jetpack on one of my clients site and he has both sharing and subscription modules on.

The sharing buttons are on posts of course and we use the subscriptions widgets to capture emails and sent out new posts when they are publish.

Everything works well and he's super happy, but now wondering if there's a way to have sharing options within the email that is sent out.

I don't think that there's a setting I missed somewhere. I didn't see anything in your documentation either, but wondering if this is something you're considering doing in the future? Maybe you have but decided not to, because it's just not possible?

Cheers and thanks again for all your work on an excellent plugin.

mihaela02 on "Add content of a wordpress page in colorbox"

$
0
0

Hello,

I want to place the content of a page in a colorbox.
Here is the code:
`$href = get_permalink(get_option('ProjectTheme_set_values_page_id'));
echo '<link media="screen" rel="stylesheet" href="'.get_bloginfo('template_url').'/css/colorbox.css" />';
echo '<script src="'.get_bloginfo('template_url').'/js/jquery.colorbox.js"> </script>';
?>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery- ui.min.js"></script>
<script>
var $ = jQuery;
$.colorbox.settings.load = true;
$(document).ready(function(){
$.colorbox({closeButton:false, overlayClose:false, escKey:false, iframe:true,
href:"$href"} );
});
</script>`
It appear a small colorbox without any contentt. What is wrong whih this code? Which is the correct value for href in order to display the page?

tonita on "Edit theme so it supports custom navigation menus"

$
0
0

Hi, everybody!

I am working on a website that must have 2 language versions - for example English and Spanish.

I tried Polylang plug-in, but it didn't work for the menus (they disappear from the page). As I understood from Polylang documentation, the theme must support custom navigation menus.

The menu function (in functions.php) is declared as it follows:

// register menu
register_nav_menus(array(
'top-header-menu' => __('Top Header Menu', 'legal'),
'footer-menu' => __('Footer Menu', 'legal')
));

And it is called in the template like that:

<?php
if (has_nav_menu('top-header-menu')) {
$legal_defaults = array(
'theme_location' => 'top-header-menu',
'container' => 'div',
'container_class' => 'theme-nav navbar-collapse collapse',
'container_id' => 'example-navbar-collapse',
'echo' => true,
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s',
'depth' => 0,
);
wp_nav_menu($legal_defaults);
}
?>

Can you, please tell me, how can I rework both functions, so I can use Polylang plug-in and translate the website?

Thank you in advance!

https://wordpress.org/plugins/menu/

kalsan on "Managing a database from the admin area"

$
0
0

Dear forum,

I'm struggeling with the philosophy of WordPress and I'd like to know what "the WordPress" way would be to manage a database from the administrative interface.

To illustrate my needs, consider the following toy example:
ToyAnim: A WordPress plugin that displays animated circles using shortcodes. In any post, the user may enter [toyanim template="crazy-red-one" /]. The plugin would then look in its animation database for an animation object with the ID crazy-red-one, load all the values (e.g. radius 50, color red, background white, speed 200, threshold 2, randomness 80 etc.) and substitute the shortcode by an animated circle.
ToyAnim would provide a menu in the administrative interface: ToyAnim -> Manage animations. Clicking the menu entry would open a list of the user-defined animations that the user can edit or delete, as well as a button "add new animation". When creating a new anim or editing an existing one, another admin page should open and display a form letting the user enter the new values for the animation (name, radius, color, ...). Upon pressing the "Save"-button, the database would be updated and thus all the shortcodes referring to that animation ID would produce a different animation (whee!).

My problem is how to modify the database from the administrative area. I tried to use a menu page and I managed to read in content of a custom table. However:
-> I don't know how I could implement the "Add new animation"- or "Edit"-Buttons: What would href be? Writing something like <a href="<?php echo plugins_url('editor.php', __FILE__); ?>">Edit</a> produces a working link, but since editor.php is an admin page, it is simply wrapped in <div class="wrap"><p>content</p></div>, therefore the page is not displayed correctly as it would if a menu button pointing to it was clicked.
-> For the same reason, I don't know what action of the edit form would be. Outside WordPress I'd simply have used something like <form method="post" action="submit.php">...</form>, but here submit.php cannot be used as action since admin pages are called in WordPress using GET, not the direct URL pointing to them.

I conclude that I'm thinking the wrong way. Alternative solutions would be to forget the idea of a custom data base and:
-> Save my animation objects as custom post types. This doesn't seem very elegant to me, since we're not really talking about posts (animation objects are simply read when generating the shortcode, never displayed to the visitor).
-> Or save them as options: again, this seems wrong since animation objects are not options. Especially, a user may create an arbitrary amount of them which is conceptually different from static options.

So what would be the WordPress way to save / edit such animation objects?

Sorry for the long post! I hope the toy example illustrates my need well enough. I'm happy to clarify anything that I explained badly. Any idea would be much appreciated.

Cheers,
Kalsan

gigibit on "Whatsapp sharing link preview isn't shown"

$
0
0

I have developed a website with WordPress, which is mainly used in mobile phones. I want to allow users to share link with their Whatsapp-friends directly from a page. I have tried something like : whatsapp://send?text='. get_permalink() .' but it just send the text, i want something like preview, otherwise send an image with a followed caption with the related link,

How can I do?


modifiedcontent on "Get latest posts from all sites across multisite network"

$
0
0

I tried to post this elsewhere on the WordPress forums, I think that broke some rules again. Mercy!

What is the latest, best solution to get recent posts from across a multisite network on your central home page?

The network-latest-posts plugin is not a solution; it requires you give it blog ID's from the blogs in your network.

I am looking for an aggregator that automatically collects the latest posts from dozens, maybe hundreds of sites, without killing the server.

The solution should probably use wp_get_sites() + get_last_updated().

This proof-of-concept snippet is floating around:

<?
$blogs = get_last_updated();
echo '
<h1>Last posts in network</h1>
';
foreach ($blogs AS $blog) {
echo "
<h2>".$blog["domain"].$blog["path"]."</h2>
";
switch_to_blog($blog["blog_id"]);
$lastposts = get_posts('numberposts=1');
foreach($lastposts as $post) :
setup_postdata($post);
the_title();
endforeach;
restore_current_blog();
}
?>
`

This post from 2011 has some kind of solution, but it is producing an annoying syntax error and I can't figure out how to fix it:

http://www.smashingmagazine.com/2011/11/wordpress-multisite-practical-functions-methods/

So what is the latest? Has anyone else worked on this? Can someone put this together, point me in the right direction?

I have another old multisite network latest posts aggregator script that I could post, but it looks very messy.

WanderlustShutter on "how to use wp dropdown users instead of login in wp login form"

$
0
0

Hello

I would like to use wp_dropdown_users as login in wp_login_form. Any ideas how to combine those two functions?

dalemoore on "How to filter custom posts by date through the URL?"

$
0
0

I'm still learning PHP, so I apologize if this is a dumb question.

I've been trying to figure out how to make a form that will allow to view posts only from a specific year. I know that WP_Query has the ability to do this using "year", but how do you do it through a URL? For instance, like going to http://site.com/custom-post-type/?orderby=date&order=DESC&year=2015 would show all posts from 2015, in descending order by date. Is this not how it should work?
So, I want a select dropdown that gets populated with all of the posts from a specific custom post type's years. There are currently only posts from 2015 and 2016 in this CPT, so 2015 and 2016 should be in the dropdown. And when you click 2016, and submit, it should then display only the CPT posts from 2016.

$args = array(
       'post_type' => array('plant'), // display only Plants; otherwise, every post type is shown
       'orderby' => $order_by, // this comes from a select, options of date, title, menu_order, and random currently
       'order' => $order, // this comes from a select, ASC and DESC are the options
       'posts_per_page' => $posts_per_page,
       'paged' => $paged,
       'year' => $year, // here lies the issue. If I hard code in 2015 here, it works on the page itself but not through the URL. How to pass into this through the URL?
);

// The Loop
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) : ?>

I'll probably take a break and come back later and it will slap me in the face... but I'm stumped.

Adam on "Show "Custom Fields" meta box for all user roles?"

$
0
0

I'm trying to figure out how to allow all logged-in users, regardless of role, see the "Custom Fields" meta box on pages and posts. From initial testing, it appears that only users with the edit_published_posts and edit_published_pages permissions can see these. I have users which don't have those roles, but do have the edit_posts and edit_pages roles.

I looked through the core code and I don't see where those permissions are checked with regards to rendering the meta box preferences.

Anyone have tips or thoughts on this?

Andy on "wp_generate_password() issues when using custom regexp for passwords"

$
0
0

Hello,

In my project I must use a custom RegExp when generating a password. wp_generate_password() function is used in lots of places in WP, not necessary for users' password.

If I let default password generation using wp_generate_password() function, passwords might not pass my custom RegExp, so I wanted to use filter in this function to overwrite the password if RegExp fails, but as filter doesn't receive parameters which wp_generate_password() function receives in my custom password generation function I don't know what restrictions should generated password have as I receive as parameter only generated password, so I know the length.

I could, of course, get each char of the password and check if they are from a specific set of characters and decide if $special_chars and $extra_special_chars where provided, but that's an overhead to the function and also because password is randomly generated I couldn't know if password should contain $special_chars or $extra_special_chars.

If I use only my password generator to match my RegExp, lost password token will fail so users will not be able to retrieve new passwords.

Best solution I see is to send $special_chars and $extra_special_chars as parameters to the filter:

return apply_filters( 'random_password', $password, $special_chars, $extra_special_chars );

Regards,
Andy

Viewing all 8245 articles
Browse latest View live




Latest Images