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

LauraN14 on "Password problem"

$
0
0

Not sure if this is the right place and sorry if it's not.
I took over a blog for a company when the old administrator left a few years ago. As I was all ready with the company I had my own admin rights on the blog and knew the passwords to do everything in regards to it, or so I thought.
Today I tried to install a plug-in, nothing fancy and it brought up a "Connection Information Screen" with log-in information for Hostname, Username and a Password field. The user is one that doesn't exist on the server and I'm not sure what exactly is going on.
I've never actually installed plugins before so I'm not even sure what the username or password should be. I've tried searching the forums but I can't seem to find anything.
I also looked in the phpadmin databases associated with the blog and for some reason the blog name is different on the backend of cpanel and the phpadmin database name.
All I want to do is install a plug-in and I'm not sure how to go about it with the username issues (or the differing database names). Help?


Julien on "taxonomies custom post types for member not display"

$
0
0

Hello,

Im trying to create some custom post types inside a plugin and a member role with capabilities but maybe something wrong.

So, I wrote this :

if ( ! function_exists('voyages_type') ) {

function voyages_type() {

	$labels = array(
		'name'                => _x( 'Voyages', 'Post Type General Name' ),
		'singular_name'       => _x( 'Voyage', 'Post Type Singular Name' ),
		'menu_name'           => __( 'Voyages' ),
		'parent_item_colon'   => __( 'Parent Item:' ),
		'all_items'           => __( 'All Items' ),
		'view_item'           => __( 'View Item' ),
		'add_new_item'        => __( 'Add New Item' ),
		'add_new'             => __( 'Add New' ),
		'edit_item'           => __( 'Edit Item' ),
		'update_item'         => __( 'Update Item' ),
		'search_items'        => __( 'Search Item' ),
		'not_found'           => __( 'Not found' ),
		'not_found_in_trash'  => __( 'Not found in Trash' ),
	);
	$rewrite = array(
		'slug'                => 'voyages',
		'with_front'          => true,
		'pages'               => true,
		'feeds'               => true,
	);
	$capabilities = array(
		'edit_post'           => 'edit_voyage',
		'read_post'           => 'read_voyage',
		'delete_post'         => 'delete_voyage',
		'edit_posts'          => 'edit_voyages',
		'edit_others_posts'   => 'edit_others_voyages',
		'publish_posts'       => 'publish_voyages',
		'read_private_posts'  => 'read_private_voyages',
	);
	$args = array(
		'label'               => __( 'voyage_post_type' ),
		'description'         => __( 'Voyage Description' ),
		'labels'              => $labels,
		'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'trackbacks', 'revisions', 'custom-fields', 'page-attributes', 'post-formats', ),
		'taxonomies'          => array( 'category', 'post_tag' ),
		'hierarchical'        => true,
		'public'              => true,
		'show_ui'             => true,
		'show_in_menu'        => true,
		'show_in_nav_menus'   => true,
		'show_in_admin_bar'   => true,
		'menu_position'       => 5,
		'menu_icon'           => 'dashicons-admin-site',
		'can_export'          => true,
		'has_archive'         => true,
		'exclude_from_search' => false,
		'publicly_queryable'  => true,
		'query_var'			  => true,
		'rewrite'             => $rewrite,
		'capabilities'        => $capabilities,
		'capability_type'     => array("voyage", "voyages"),
		'map_meta_cap'        => true,
	);
	register_post_type( 'voyage_post_type', $args );
}
add_action( 'init', 'voyages_type', 0 );

}

function add_voyages_caps_to_admin() {
	$caps = array(
		'read',
		'read_voyages',
		'read_private_voyages',
		'edit_voyages',
		'edit_private_voyages',
		'edit_published_voyages',
		'edit_others_voyages',
		'publish_voyages',
		'delete_voyages',
		'delete_private_voyages',
		'delete_published_voyages',
		'delete_others_voyages',
	);
	$roles = array(
		get_role( 'administrator' ),
		get_role( 'editor' ),
		get_role( 'contributor' ),
		get_role( 'author' ),
		get_role( 'client' ),
	);
	foreach ($roles as $role) {
		foreach ($caps as $cap) {
			$role->add_cap( $cap );
		}
	}
}
add_action( 'after_setup_theme', 'add_voyages_caps_to_admin' );

The problem is :
I can see like post, everything (category and tag) when im logging as ADMIN but when im logging as "client" role, I can'T see category and tag. I don't know why.

SOmeone can help me please ?

Thank you

matobodo on "Plugin character encoding problem"

$
0
0

I'm writing a plugin and i have problem with character encoding. i'm using characters e.g. (ľ,š,č,ť,ž,ý). Here is code:

add_action('admin_menu', 'receptar_admin_actions');
function receptar_admin_actions() {
    add_menu_page('Receptár', 'Receptár', 'manage_options', __FILE__, 'receptar_admin', plugins_url( __FILE__ . 'images/icon.png' ), 26);
}

i don't know how to fix it. i'm sorry if already is here this topic but i haven't found it

thanks for any help

Sorry for my english

CLehnert on "Need to Remove Login and Lost Password Links from beneath "Register" form"

$
0
0

Most importantly, I need to remove the "Login" link that appears below the "Register" form. Strangely, I can use this to remove the "Register" link from below the login page, but it does not work to remove anything from the Register page:

add_filter('register', 'remove_links');
		function remove_links() {
			unset($login_url);
		}

Is there any type of filter or hook I can use to remove these two links? I need to make sure only the registration form is available to prevent malicious users from accessing the login form. Any help here is greatly appreciated.
CSS display: none will not be sufficient, because the links are actually still accessible in the page, just not visible. Removing them with jQuery is also not ideal, because this can be circumvented.
Thanks

raybeam on "Custom Fields Plugins - How to properly output"

$
0
0

Hi,

I'm trying to develop a custom field for a website I am designing. The client needs to display facilities for properties. I am able to create a custom field in my backend that allows me to input and save new facilities. However, I am having trouble properly outputting that to the front end.

What I want is to output what the user puts into the input field in a nicely styled way. I have followed about 3 wptuts tutorials but none of them have solved my problem and all of them had error messages when I run them. Below is the code I have written so far:

<?php
/********************************************************************/
/* WORKING ON CUSTOM FIELDS */
/*********************************************************************/
add_action( 'admin_init', 'facilities_admin' );

function facilities_admin() {
	add_meta_box(
		'facilities_meta_box',
		'Facilities',
		'display_facilities_meta_box',
		'post',
		'normal',
		'high'
	);
}

function display_facilities_meta_box( $facility ) {
	$facility_text = esc_html( get_post_meta( $facility->ID, 'facility_text', true) );

	?>
	<label for="facility_meta_box_text">Facility: </label>
	<input type="text" id="facility_meta_box_text" name="facility_meta_box_text" value="<?php echo $facility_text; ?>" />

	<?php
}

add_action( 'save_post', 'facilities_fields', 10, 2 );

function facilities_fields( $facility_id, $facility) {
	if ( $facility->post_type == 'post') {
		if ( isset( $_POST['facility_meta_box_text'] ) && $_POST['facility_meta_box_text'] != '' ) {
			update_post_meta( $facility_id, 'facility_text', $_POST['facility_meta_box_text'] );
		}
	}
}

function display_facilities() {
	global $post;
	$facility_text = esc_html( get_post_meta( $facility->ID, 'facility_text', true) );

	$allowed_html = array(
		'a' => array(
			'href' => array(),
			'title' => array()
		),
		'em' => array(),
		'strong' => array()
	);

	$_facility_name_output = wp_kses($facility_text[0], $allowed_html);
	$output = '<div class="row">
				<div class="col-md-6">
					<div class="facilities-container">
						<h6 class="facilities-header">Facilities</h6>
						<ul class="project-info">
							<li>'.$_facility_name_output.'</li>
						</ul>
					</div>
				</div>
			</div>';
			return $output;
}
add_shortcode( 'review-box', 'display_facilities' );

Basically, I'm not a very experienced programmer, more of a pseudo-programmer, if such a term can be used, and I don't really understand how to change this code to work for me. When I run it, I get the message "undefined variable: facility_text" so how do I get my function to recognise the variable which has been declared in the "display_facilities_meta_box".

I would really appreciate some help.

Thanks

fharper on "Deactivating TinyMCE keyboard shortcut"

$
0
0

I'm using the latest version of Wordpress, and when I try to use ALT + 0 to do a right square bracket (I'm using a French keyboard), I got an accessibility help dialog from TinyMCE. Is there a way to deactivate this dialog, this shortcut or all keyboard shortcuts for TinyMCE?

I didn't find anything, any idea?

remopini on "qTranslate and Page Builder (from Divi Theme)"

$
0
0

Whenever I have qTranslate active, I get PHP errors in post.php (line 731, vta is null) when I edit any parts of a page using Page Builder (instead of the standard page editor).

This seems to happen, because qTranslate doesn't create language tabs on the text boxes managed through page builder and so crashes when trying to access the content of those boxes.

Has anyone already seen and fixed this problem?

hiphopinenglish on "Custom Taxonomy Meta Field for Bandcamp embed"

$
0
0

I've been using Custom Taxonomies for a while, so I'm quite familiar with them. However, on my latest project, I've found myself stumped by something. I'm creating Meta Fields for a Custom Taxonomy, and whilst they work great for links, and dates, and basic information like that, I'm having issues using them with embed codes from Bandcamp (And Soundcloud).

// Add Showcase Meta Field to custom taxonomy

// Add term page
function taxonomy_add_new_meta_field_showcase() {
	// this will add the custom meta field to the add new term page
?>
	<div class="form-field">
		<label for="term_meta[showcase_meta]"><?php _e( 'Paste PRODUCER Showcase here, or album Bandcamp/Soundcloud link.', 'producers' ); ?></label>
		<input type="text" name="term_meta[showcase_meta]" rows="4" cols="50" id="term_meta[showcase_meta]" value="">
		<p class="description"><?php _e( 'Paste PRODUCER Showcase here, or album Bandcamp/Soundcloud link.','producers' ); ?></p>
	</div>
<?php
}
add_action( 'hhie_producers_add_form_fields', 'taxonomy_add_new_meta_field_showcase', 10, 2 );
//Edit function for custom meta field

// Edit term page
function taxonomy_edit_meta_field_showcase($term) {

	// put the term ID into a variable
	$t_id = $term->term_id;

	// retrieve the existing value(s) for this meta field. This returns an array
	$term_meta = get_option( "taxonomy_$t_id" ); ?>
	<tr class="form-field">
	<th scope="row" valign="top"><label for="term_meta[showcase_meta]"><?php _e( 'Paste PRODUCER Showcase here, or album Bandcamp/Soundcloud link.', 'producers' ); ?></label></th>
		<td>
			<input type="text" name="term_meta[showcase_meta]" rows="4" cols="50" id="term_meta[showcase_meta]" value="<?php echo esc_attr( $term_meta['showcase_meta'] ) ? esc_attr( $term_meta['showcase_meta'] ) : ''; ?>">
			<p class="description"><?php _e( 'Paste PRODUCER Showcase here, or album Bandcamp/Soundcloud link.','producers' ); ?></p>
		</td>
	</tr>
<?php
}
add_action( 'hhie_producers_edit_form_fields', 'taxonomy_edit_meta_field_showcase', 10, 2 );

//Save function for custom meta field
// Save extra taxonomy fields callback function.
function save_taxonomy_custom_meta_showcase( $term_id ) {
	if ( isset( $_POST['term_meta'] ) ) {
		$t_id = $term_id;
		$term_meta = get_option( "taxonomy_$t_id" );
		$cat_keys = array_keys( $_POST['term_meta'] );
		foreach ( $cat_keys as $key ) {
			if ( isset ( $_POST['term_meta'][$key] ) ) {
				$term_meta[$key] = $_POST['term_meta'][$key];
			}
		}
		// Save the option array.
		update_option( "taxonomy_$t_id", $term_meta );
	}
}
add_action( 'edited_hhie_producers', 'save_taxonomy_custom_meta_showcase', 10, 2 );
add_action( 'create_hhie_producers', 'save_taxonomy_custom_meta_showcase', 10, 2 );

When calling this in my page template, I get the weirdest output when using <iframe>from Bandcamp. Here's the code that I've used on my page template:

<?php $array=get_option('taxonomy_' . $term->term_id); ?>
			<?php $showcase=$array['showcase_meta']; ?>
			<?php if ( !empty( $showcase) ) : ?>
			<div class="producershowcase">
			<?php echo wpautop( $showcase) ; ?>
			<?php endif; ?>
			</div>

I've also tried without wpautop but to no avail.

I've also tried using textarea rather than textas my input type, and that hasn't worked either.
Hopefully, someone can shed some light - I may well have neglected somethnig very obvious. Thanks.
(Current output can be seen here - notice the weird iframe of my site instead of the intended Bandcamp one)


raytri on "Control display order of "available widgets" on widgets screen"

$
0
0

I've looked around for an answer to this, and found nothing -- not even the question!

I'm building a site that includes several custom widgets. Everything works fine, but on the Appearance -> Widgets screen, my custom widgets are mixed in randomly with all the default widgets in the "Available Widgets" area.

My question: Is there a way (other than editing widgets.php) to control the order in which widgets are listed under "Available widgets"? I don't care if my custom widgets are listed first or last -- I'd just like them to be grouped together.

Thanks!

epiric on "Default Gallery fails HTML validation"

$
0
0

Hello. I tryed Googling around for my issue.. But i think i didnt manage to find exactly what im looking for. The thing is that i have few subpages with gallery (default wordpress that opens in Lightbox(but thats not issue) and when i went to w3c validation for html5 it failed. It gives me
"Element dl is missing a required instance of child element dd."
</dt></dl><dl class='gallery-item'>"

Im not using titles on my images, is that a problem? Because i dont need them. Is there any way to edit functions.php for gallery to stop echoing this? What will i loose if it stops,and will i have to redo all galleries again so it applies to them? I tryed removing that attribute in media.php but nothing happened.
Thank you

kesp on "Exclude posts from first loop in second loop"

$
0
0

Hi,

I've created a related posts function for the end of my single.php that has 2 loops. The first loop displays related posts by tag and then if there's not enough of those then the second loop kicks in and displays some recent posts from the same category.

The idea is that i always want to show 4 related posts but i haven't always got enough related by tag so when that happens i display a few from the same category to pad it out.

Both loops exclude the current post id, however, the problem i have is that it is possible for a post to be returned in the first tag loop and the second by-category loop, so i end up with 2 of the same in the related posts

What I want to do is exclude any posts returned in the first by-tag loop from the second by-category loop.

I've been trying to implement something this solution but not much luck

http://stackoverflow.com/questions/12539952/two-loops-exclude-post-from-first-loop-in-second-loop

Here's my code:

<?php
        $orig_post = $post;
        global $post;
        $tags = wp_get_post_tags($post->ID);
         $max_articles = 4;  // How many articles to display
		 $cnt = 0;

        if ($tags) {
       	 $tag_ids = array();
       	 foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
       	 $args=array(
        'tag__in' => $tag_ids,
        'post__not_in' => array($post->ID),
        'posts_per_page'=> $max_articles, // Number of related posts to display.
        'caller_get_posts'=>1 ,
		'tag__not_in' => array('480'),
		'orderby' => 'date',
		'order' => 'DESC'

        );  

        $my_query = new wp_query( $args );
	$exclude_featured = array();

        while( $my_query->have_posts() ) {
        $my_query->the_post();
		$cnt++;
		$exclude_featured = $post->ID;

        ?> <?php the_title(); ?>  	

        <? }
        }
        $post = $orig_post;  

         if ($cnt < $max_articles) {
		 			 $args=array(
		'category_name' => $category[0]->cat_name,
        'post__not_in' =>  array($post->ID),
        'caller_get_posts'=>1
        );  

				 			 $blah=array(
        'post__not_in' =>  array($exclude_featured)
        );
       $mergeblah = array_merge( $args, $blah );
        $relQuery = new WP_query( $mergeblah );  

		if($relQuery->have_posts()) : 

		while($relQuery->have_posts()) : $relQuery->the_post();
		            $cnt++;
                if ($cnt > $max_articles) break;
		?>
		        <?php the_title(); ?>
		<?php
		endwhile;

		else :
			//do nothing
		endif;

		 }
		wp_reset_postdata();
        ?>

Any pointers much appreciated.

Thanks,

Kes

umchal on "wp_http_supports( array( 'ssl' ) ) yeilds true on a local server"

$
0
0

Hi there,

The function call wp_http_supports( array( 'ssl ) ) always returns true on my local server which does not enable ssl connection.

Is it normal?

WordPress 3.8.1
PHP 5.2.4
Apache 2.2.22

Looic on "get_terms : query by exact term_name, help needed"

$
0
0

Hello All!
I cannot making it work.

I have the following custom taxonomy structure (category like) :
A
\--My Sub Term Parent A
\--My Sub Term Parent Abis

Now I want to get the FIRST sub-term object so I query like that:

$query_term = array(
            'parent'        => 804, // id of term "A"
            'search'        => esc_attr("My Sub Term Parent A")
);
$cat_term_obj = get_terms($my_tax, $query_term);

The problem is it doesn't allow me to retrieve the exact match of the queried term name. It retrieves nothing (null). I tried with name__like parameter but it's the same.

Is there a way to retrieve a term in a custom taxonomy name, b ased on the exact term name ?

Thank you for your help,
Looic.

oriolo on "How to use get_sidebar in plugin folder?"

$
0
0

I've created the plugin that adds custom post type and custom taxonomies for this post type. Templates for the post type and the taxonomies are located in plugin folder.

Now I need to add sidebar for the post type and taxonomies pages. I've tried to use the following code for sidebar:

function mytype_get_sidebar($mytype_sidebar) {
// load sidebar template
if (file_exists(plugin_dir_path(__FILE__) . '/sidebar-mytype.php'))
    return plugin_dir_path(__FILE__) . '/sidebar-mytype.php';

// Default return
return $mytype_sidebar;
}
add_filter('get_sidebar', 'mytype_get_sidebar');

And then on the page where the sidebar should be:

get_sidebar ( apply_filters( 'mytype_get_sidebar', '' ) );
But it doesn't work. var_dump returns NULL:

$my = get_sidebar ( apply_filters( 'mytype_get_sidebar', '' ) );
var_dump($my);

Is there any way how to do that?

Thanks in advance.

claybaby on "javascript fail to load"

$
0
0

I'm using some javascript written by a previous site-builder for an html site. I did get it to work in the past, but something changed and I can't get the javascript file to load and work. The path to the file appears correct, but the console says "failed to load..."

I tried to load the file within the post and in the header, neither worked.

The javascript file contains a function like this:

var co = new Object;
function recalc_onclick(ctl) { if...etc

In the codex it says

For the occasional or one time use of JavaScript, you need to put the script into a JavaScript file, and then call it out from within the post. Make sure that each script is defined by its function name, such as:

I'm not sure what that means?

the function is called within the post like this

<script language="javascript" type="text/javascript">
 function reset_onclick(x){document.formc.reset();postcode();recalc_onclick('');};function postcode(){document.formc.p3C45.value="John/Jane Doe";document.formc.p3C46.value="Company Name";document.formc.p3C47.value="email @ domain.com";};function eequerystring(){var querystring=document.location.search;if(querystring.length>0){variables=(querystring.substring(1)).split("&");var variable;var key;var value;for(var ii=0;ii<variables.length;ii++){variable=variables[ii].split("=");key=unescape(variable[0]);value=unescape(variable[1]);if(document.formc[key]!=null){document.formc[key].value=value;}}}}function initial_update(){postcode('');eequerystring();recalc_onclick('');}
</script>

It's doing a whole bunch of math to fill in a table based on input values(there are some default values).


maxgx on "creating array of post IDs to exclude from custom loop"

$
0
0

i'm using Metaphor Shortcodes plugin to display posts ("post blocks" as they're called in the plugin) in a widget area placed at the top of a custom loop, through the use of its shortcodes.

shortcodes share most settings (thumbnail size, excerpt length, etc.), so i resorted to use Shortcode Exec PHP to simplify the shortcode to be used.
a shortcode like:
[mtphr_post_block id="774" thumb_size="full" excerpt_length="50" excerpt_more=""]
now looks like:
[post_this id="774"]

in Shortcode Exec PHP i've this:

extract(shortcode_atts(array('id' => ''), $atts));
echo do_shortcode('[mtphr_post_block id="'.$id.'" thumb_size="full" excerpt_length="50" excerpt_more=""]');

what i need now is a way to hide these posts from the loop that runs just below the sidebar.

i've tried storing the posts' IDs into an array, then test if the post ID in the loop matches one of those in the array.

i've created a function in functions.php to create a global the array:

$arrayExcludedPosts = array();
// Set a global array for posts to exclude from custom loop
function arrayExclude($val) {
	global $arrayExcludedPosts;
	$arrayExcludedPosts[] = $val;
	return $arrayExcludedPosts;
}

then added a line in Shortcode Exec PHP to call the function and store the ID in the global array:

arrayExclude($id);
extract(shortcode_atts(array('id' => ''), $atts));
echo do_shortcode('[mtphr_post_block id="'.$id.'" thumb_size="full" excerpt_length="50" excerpt_more=""]');

then the IF statement in the loop:

<?php while ( $custom_query->have_posts() ) : $custom_query->the_post(); ?>
  <?php if (!in_array($post->ID, $arrayExcludedPosts)): ?>
    <?php get_template_part( 'content', get_post_format() ); ?>
  <?php endif; ?>
<?php endwhile; ?>

but apparently no ID is being added to the array.

trying to print what the function returns shows an empty array:

<?php print_r(arrayExclude()); ?>
// output:  Array ( [0] => )

i think i'm missing some crucial point... can anyone help me out with this?
thanks in advance!

qdungeng on "get post from slect field ACF"

$
0
0

Dear friend

I did install ACF (advanced Custom fields) and Create Select Field "Hotel_in", and more choices :
SG : Saigon
HN : Hanoi
HC : Hue City

...

Please help me how to get all post title and URL from single field and get label from single choices .

I did use :

if(get_field('hotel_in') == "HG")
{
//...
}

But it not working. Please help me.
Thanks

qdungeng on "Please help me to this code"

$
0
0
<?php
global $post;
$category = get_the_category($post->ID);
$category = $category[0]->cat_ID;
$myposts = get_posts(array('numberposts' => -1, 'category__in' => $category));
foreach($myposts as $post) :
setup_postdata($post);
?>

<?php
$field = get_field_object('hotel_in');
$value = get_field('hotel_in');
$label = $field['choices'][ $value ];
$posts = get_posts(array(
	'numberposts' => -1,
	'meta_key' => $field,
	'meta_value' => $value
));

if($posts)
{
	echo 'Hotel in ' .$label .'<ul>';

	foreach($posts as $post)
	{
		echo '<li><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></li>';
	}

	echo '</ul>';
}

?>

<?php endforeach; ?>
<?php wp_reset_query(); ?>

Error to display :
Warning: trim() expects parameter 1 to be string, array given in D:\xampp\htdocs\newdh\wp-includes\meta.php on line 774
Please help me.

Thanks a lot.

raybeam on "Dynamically Create new table items in a CUSTOM field"

$
0
0

Hello,

I was wondering if any of you amazing programmers out there might be able to help me with something. I want to create a custom field, i.e build my own "custom" custom field that allows the user to dynamically add new table items depending on how many they need. For example, say the user creates a new post and in this post he wants to add information such as, information about the units in a condo. Lets say some condos have 2 units to showcase, while others have 5 or 6 or any number. How could I set it up so I could add new table rows dynamically from the back end?

I imagine something intuitive like a plus symbol under the default table rows that allowed the user to easily add a new input field.

Here are some of the project requirements:

1) Must have 5 columns
2) Undefined number of rows but say a base number of about 4 rows
3) When user adds new item, it must add all the columns needed: unit size, number of beds, Size Meter Square, Price from, Price to
4) Newly added rows must update and be added to the database (of course)

I know how to create the main body of the code here.. I just don't know how to add a function that will allow me to increment a new table row with table data included.

Any help will be much appreciated

Thanks

arun.s on "error on category section"

$
0
0

getting this error on category selection tab

Warning: call_user_func() expects parameter 1 to be a valid callback, no array or string given in /home/blog14/public_html/wp-admin/includes/template.php on line 928

please suggest the needful changes to be done to resolve this error

thanks

Viewing all 8245 articles
Browse latest View live


Latest Images