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

doolezah on "Filter the Categories Widget by limiting categories to one term of a taxonomy"

$
0
0

I would like to create a custom Categories widget that lists only the categories found in posts belonging to a specific term from a taxonomy. I have created a new custom categories widget that extends the default Categories widget, but I cannot figure out how to set the arguments to limit the results. I have tried multiple approaches to setting up the arguments, but to no avail.

Does anyone have any suggestions?

Also, to help think about this, each taxonomy term is an area of interest similar to a newspaper section. Those taxonomy terms have a 'home page' that should have all sidebar items filtering out any sibling or parent terms and showing only the ones within posts to the section. I appreciate the help!


georgemathew46 on "Change Profile Picture and Display Name text link to Author Page"

Mitchell Bennis on "WP-Login Tweak to Stop Unauthorized Access and Keep Hackers Out"

$
0
0

Would love some feedback on this tweak that disallows general access to the login.php page. It requires that a PIN be passed to the login page. No PIN, no access, goodbye. Sick of the bad guys pounding on my websites.

// Wordpress Tweak - Stop Unauthorized Access - Keep Hackers Out
// Author: mitchellbennis@gmail.com - rev 11.30.15
// 1) Add this snippet to the top of the Wordpress wp-login.php file, right after the bootstrap line.
// 2) Create a PIN and update the constant
// 3) Pass the PIN thru the login URL in order to access the page: /wp-login.php?eePIN=xxxx
// ... Otherwise you get redirect away and never see the login form. So long bad guys...

// The page access PIN
define('eePIN', 'xxxxx'); // Set to whatever your heart desires.

// The Redirect URL
define ('eeAWAY', 'http://elementengage.com/welcome-hackers/'); // Same same, but you can leave it like this.

if(@$_POST['log'] OR (@$_GET['action'] == 'logout' AND check_admin_referer('log-out'))) { // Login or Logout
	// Proceed normally

} elseif(@$_GET['loggedout']) {  // Logged out

	header('Location: http://' . $_SERVER['HTTP_HOST']);
	exit;

} else {

	// This PIN must be passed in order to access this page
	$thePIN = @$_GET['eePIN'];
	if($thePIN != eePIN) {
		header('Location: ' . $eeAway);
		exit;
	}
}

More info

FelixHansar on "[Theme: Bridge]: Javascript modification - Open sidebar with custom button"

$
0
0

Hi,

I am facing a very easy to fix problem, but because I have no idea about Java I am completely lost.

Bridge theme has a sidebar included as you can see in this Demo (3 stripes at the top of the screen).

I am looking into creating a button on the page with a class which will make the sidebar open. I already reached out to the support and got this answer:

Inside theme folder / js / default.js file search for this code http://screencast.com/t/Grg22YhLfLxs. The code is responsible for opening and closing sidebar, and you have to be able to use this function and to modify it according to your needs.

You can create button, and to specify ID like on screenshoot http://screencast.com/t/gWwzr4LHur (or create it on any other way but specify that ID). After that use its ID inside your function in order to target it, and you can add your modified function from Qode Options > General > Custom Code > Custom JS.

So I took a look at the default.js anf I think I found the code I snippet I need to modify:

var current_scroll;
function initSideMenu(){
	"use strict";

	if ($j('body').hasClass('side_area_uncovered_from_content')) {
		$j('.side_menu_button_wrapper a.side_menu_button_link,  a.close_side_menu').click(function(e){
			e.preventDefault();
			$j('.side_menu').css({'right':'0'});
			if(!$j('.side_menu_button_wrapper a.side_menu_button_link').hasClass('opened')){
				$j('.side_menu').css({'visibility':'visible'});
				$j(this).addClass('opened');
				$j('body').addClass('right_side_menu_opened');
				current_scroll = $j(window).scrollTop();

				$j(window).scroll(function() {
					if(Math.abs($scroll - current_scroll) > 400){
						$j('body').removeClass('right_side_menu_opened');
						$j('.side_menu_button_wrapper a').removeClass('opened');
						var hide_side_menu = setTimeout(function(){
							$j('.side_menu').css({'visibility':'hidden'});
							clearTimeout(hide_side_menu);
						},400);
					}
				});
			}else{
				$j('.side_menu_button_wrapper a.side_menu_button_link').removeClass('opened');
				$j('body').removeClass('right_side_menu_opened');
				var hide_side_menu = setTimeout(function(){
					$j('.side_menu').css({'visibility':'hidden'});
					clearTimeout(hide_side_menu);
				},400);
			}
		});
	}

	if ($j('body').hasClass('side_menu_slide_with_content')) {
			$j('.side_menu_button_wrapper a.side_menu_button_link, a.close_side_menu').click(function(e){
			e.preventDefault();

			if(!$j('.side_menu_button_wrapper a.side_menu_button_link').hasClass('opened')){
				$j(this).addClass('opened');
				$j('body').addClass('side_menu_open');
				current_scroll = $j(window).scrollTop();
				$j(window).scroll(function() {

					if(Math.abs($scroll - current_scroll) > 400){
						$j('body').removeClass('side_menu_open');
						$j('.side_menu_button_wrapper a').removeClass('opened');
					}
				});
			}else{//hamburger icon has class open on its click
				$j('body').removeClass('side_menu_open');

				$j('.side_menu_button_wrapper a.side_menu_button_link').removeClass('opened');
				$j('body').removeClass('side_menu_open');

			}

			e.stopPropagation();
			$j('.wrapper').click(function() {
				e.preventDefault();
				$j('body').removeClass('side_menu_open');
				$j('.side_menu_button_wrapper a.side_menu_button_link').removeClass('opened');
				$j('body').removeClass('side_menu_open');
			});
		});
	}

	if ($j('body').hasClass('side_menu_slide_from_right')) {
			$j('.wrapper').prepend('<div class="cover"/>');
			$j('.side_menu_button_wrapper a.side_menu_button_link, a.close_side_menu').click(function(e){
			e.preventDefault();

			if(!$j('.side_menu_button_wrapper a.side_menu_button_link').hasClass('opened')){
				$j(this).addClass('opened');
				$j('body').addClass('right_side_menu_opened');

				$j(' .wrapper .cover').click(function() {
					$j('.side_menu_button_wrapper a.side_menu_button_link').removeClass('opened');
					$j('body').removeClass('right_side_menu_opened');
					$j('.side_menu_button_wrapper a').removeClass('opened');
				});
				current_scroll = $j(window).scrollTop();
				$j(window).scroll(function() {
					if(Math.abs($scroll - current_scroll) > 400){
						$j('body').removeClass('right_side_menu_opened');
						$j('.side_menu_button_wrapper a').removeClass('opened');
					}
				});
			}else{
				$j('.side_menu_button_wrapper a.side_menu_button_link').removeClass('opened');
				$j('body').removeClass('right_side_menu_opened');
			}
		});
	}
}

However, I have no idea how to do that. I need your guys' help.
I would like the css class making the sidebar open to be side-open-button

Thank you for your help!

Cryoax on "PHP Name Tie-in and IP Sensitive Content"

$
0
0

Hi all,

So, for my website, I'd like a few things to be done on it, but I don't really have much experience coding. I've taken a few courses, but I'm a little lost on the application.

So the two main functions I want to add right now, are tying a name to a user when they login, and have IP-sensitive content.
(I'm using the OptimizeMember plugin, don't know if that's relevant or not.)

So for example, with the tying a name thing, on the member's home page, I'd like something to say "Welcome, %insertfirstnamehere%!".

As well as if they logged in from let's say, Virginia. How would I implement it to say something like, would you like to purchase a %insertstatenamehere% LLC? Or something like that. I basically want to track the user's IP and tie it to a state, then tie it in to the page.

Thank you so much!

GaryKay on "Returning API values from Google"

$
0
0

Hi,

I need to return json values from the google currency api. I have tried using the wp_remote_get() method but nothing is returned. Not really sure what I'm doing with it. The code snippet I'm using is from https://currency-api.appspot.com/ , the php code is

$url = "https://currency-api.appspot.com/api/USD/EUR.json?amount=1.00";

$result = file_get_contents($url);
$result = json_decode($result);

if ($result->success) {

	echo "1 USD is worth $result->rate EUR";
}

I would like to use this within a theme template page

Thanks

toneburst on "Sort Posts By Multiple Meta Values"

$
0
0

Hi,

I have written a plugin to create a custom post-type. I want to set the default sort-order for posts of this custom type when they display on their own archive page.

I've managed to get them to sort by one custom meta key value, but I need them to also be sorted by the value of a second meta key.

I want posts to be sorted by year of graduation (it's a university alumni site), then by first name.

I can't seem to get it to work, though I've found lots of posts where others are failing to do the same thing.

Here's the code I have so far:

public function majal_pre_get_posts_alumni_sortorder( $query ) {
	if ( !is_admin() && $query->is_main_query() && $query->is_post_type_archive( 'majal_alumni' ) && !isset( $_GET['orderby'] ) ) {
		$query->set( 'meta_key', '_majal_alumni_alumnus_graduationyear' );
		$query->set( 'orderby', 'meta_value' );
		$query->set( 'order', 'DESC' );
		$query->set( 'meta_query', array(
			array(
				'key'		=> '_majal_alumni_alumnus_namesecond',
				'orderby'	=> 'meta_value',
				'order'		=> 'ASC'
			)
		));
		$query->set( 'posts_per_page', '16' );
		$query->set( 'paged', true );
	}
}

This function is called by the 'pre_get_posts' filter hook. I know it's getting called correctly, as my posts are being correctly sorted on '_majal_alumni_alumnus_graduationyear', but they're not then being sorted by '_majal_alumni_alumnus_namesecond'.

I want posts with identical values for graduationyear to be grouped together, but then sorted by namesecond.

Anyone any ideas?

Kia on "Comment comes in to my wp_comment"

$
0
0

There is no comment form in my website. But spam comments come in to wp_comment. Is this code hijacking? How can I find those files? Thank you.


Abu Bakar on "How to add woocommerce product sorting dropdown on custom template?"

$
0
0

I have created a custom search page for woocommerce products. I have added the woocommerce catalog sorting dropdown using the hook. It displays fine but it does not sort product correctly. For example, when we select the option "Sort by price: High to low" , it does not sort correctly.
Is this dropdown Shop / product archive page specific?

Here is my search.php code:

<?php get_header();
    add_action(  'twb_product_sorting' , 'woocommerce_catalog_ordering'); ?>

    <div class="search-widgets">
      <h4>
        <?php _e('Define your search further'); ?>
      </h4>
      <div class="row layer">
        <div class="col-md-3"> <span style="padding-left:5px;">
          <?php _e( 'Sort By' ); ?>
          </span>
          <div class="geronimo-search-sorting"><?php do_action('twb_product_sorting'); ?></div>
        </div>
      </div>
    </div>
    <?php
       global $query_string;

     $query_args = explode("&", $query_string);

    $search_query = array(
		'post_type' => 'product',
		'posts_per_page' => -1
    );

    foreach($query_args as $key => $string) {
	$query_split = explode("=", $string);
	$search_query[$query_split[0]] = urldecode($query_split[1]);
    } // foreach

    $wp_query = new WP_Query($search_query);

    if ($wp_query->have_posts()) {

	echo'<div class="woocommerce"><ul class="products">';

	while ($wp_query->have_posts()) :

	$wp_query->the_post();

   	woocommerce_get_template_part('content', 'product');

    endwhile; // end of the loop.
    wp_reset_query();

	echo'</ul></div>';

     }else{
	 echo'No Products found matching your criteria!';
	 }
    ?>

Any help would be highly appreciated.

Thanks

firaskudsy on "wp job manager hook job_location value on submit"

$
0
0

hi , am trying to set the job_location field in automatic way by setting its value on submition form, i want to make location = region slug, any help in this issue ? i tried the hook method but i =t didnt work

dbialer on "Request for feedback: Offlining sites with service workers"

$
0
0

I am newbie to the WordPress community so please excuse me if this is in the wrong place and would appreciate suggestions for more appropriate places.

I work for Mozilla as a product manager. and my team considering how to integrate service workers into WordPress (more info on service workers: http://www.w3.org/TR/service-workers/). One use case for service workers is to cache resources (in the background) for offline use and intelligently route network fetch requests so that, for instance, a website could work on a device when not connected to a network by fetching pages from its cache. Service workers are meant to fix many of the problems of appcache. Mozilla is working on a code recipe books for using service workers (https://serviceworke.rs/), but is also thinking about real-world applications to apply such as:
1. having WordPress-created websites work offline. A plugin, perhaps, that could cache all or parts of a site, and update automatically.
2. pushing web notifications (for instance, to subscribers when a new article is posted).

My request for feedback as to whether such things sound like they could have usage, if so which one, and would you suggest we approach this as a plugin or some other way?

Thanks for your feedback.

Andrea Bazerla on "The customizer API, there is a plugin?"

$
0
0

Hi, I'm creating my first theme from 0...

I'm creating through my code custom sections, controls and settings in Appearance -> Customize with The Customizer API.

There is a plugin to make it easier and faster? Or must I write my own code to add item to customize the theme, with theme mods and options?

I'm confused, Thanks!

PavilionVI on "Tags styling problem!"

$
0
0

Hello guys;

I'm working on a custom tags page and I have one little problem that I couldn't figure out!

I put this code in the theme's functions.php

function get_tgrid() {
$wpbtags =  get_tags();
$output .= '<div class="grid"><div class="tagslist"><ul class="tagsgrid">';
foreach ($wpbtags as $tag) {
	$output .= '<li class="item"><a href="'. get_tag_link($tag->term_id) .'" style="background-image: url("/wp-content/uploads/tags/' . $tag->slug . '.jpg")"><span class="item-name"><span class="count">'. $tag->count .'</span><span class="item-name">'. $tag->name . '</span></span></a></li>';
	}
$output .= '</ul></div></div>';
return $output;
}

The problem is instead of giving the intended output which is like:
<a href="http://myblog.com/tag/example/" style="background-image: url("/wp-content/uploads/tags/example.jpg")"><span class="item-name"><span class="count">1</span><span class="item-name">EXAMPLE</span></span></a>

it gives me this:
<a href="http://myblog.com/tag/example/" style="background-image: url(" wp-content="" uploads="" tags="" example.jpg")"=""><span class="item-name"><span class="count">1</span><span class="item-name">EXAMPLE</span></span></a>

I'm a php newbie and I'd appreciate a little help!
Thanks.

tibetanitech on "Translate WordPress archive Year and count values"

$
0
0

Hello all,

I desperately need help in converting the WP archive values in our language i.e Tibetan. Since the website is build in only our language we are not using WPML. We have archive dropdown list in category.php and I could find the following code to replace the month values in archive which is working great, but i couldn't find a way to translate the year and count values. Please help.

In category.php
<select name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value="">
<?php echo esc_attr( __( 'འཚོལ།' ) ); ?></option>
<?php wp_get_archives( array( 'type' => 'monthly', 'format' => 'option', 'show_post_count' => 1 ) );
?>
</select>

In functions.php
// Translate WP archive months

add_filter('get_archives_link', 'translate_archive_month');

function translate_archive_month($list) {
$patterns = array(

'/January/', '/February/', '/March/', '/April/', '/May/', '/June/',
'/July/', '/August/', '/September/', '/October/', '/November/', '/December/'
);

$replacements = array(
'ཟླ་དང་པོ།', 'ཟླ་གཉིས་པ།', 'ཟླ་གསུམ་པ།', 'ཟླ་བཞི་བ།', 'ཟླ་ལྔ་པ།', 'ཟླ་དྲུག་པ།',
'ཟླ་བདུན་པ།', 'ཟླ་བརྒྱད་པ།', 'ཟླ་དགུ་པ།', 'ཟླ་བཅུ་པ།', 'ཟླ་བཅུ་གཅིག', 'ཟླ་བཅུ་གཉིས།'
);

$list = preg_replace($patterns, $replacements, $list);
return $list;
}

Thank you!

Nitika123 on "Does Anybody Have Facebook Like Click Jack Script"

$
0
0

I need click jack script for my blog. Just simple click jack trick to increase Facebook likes as much as possible. Here the url 4result.in


smnevans on "Best location for custom taxonomy code?"

$
0
0

I'm currently making my first site that uses custom post types and custom taxonomies.
I've set up the custom post types as plugins (as recommended) so they will still be accessible if the the theme is changed. Everything I've read about custom taxonomies, though, has the code for registering them and displaying them in the admin interface in the functions.php for the theme you are using.

Is there a better, less theme dependent, place for this code to go?

zain.mr89 on "Change wp-admin url"

$
0
0

Hi all,

I have seen many tutorials on how to change wp-admin to any other link for security reasons.
But none of the given solutions are 100% working.

I was following this link:
https://wordpress.org/support/topic/how-to-change-the-admin-url-or-wp-admin-to-secure-login?replies=13

What I want to do ?
- I want to change my wp-admin link to secret-link. To be more specific, change this link http://wordpress-site/wp-admin to http://wordpress-site/secret-link

And when anyone try to open http://wordpress-site/wp-admin or http://wordpress-site/wp-login.php he/she must be redirected to 404 Page.

What I've achieved so far ?
- Till now I am able to restrict http://wordpress-site/wp-admin
This link is redirecting to 404 Page.

Please help. Thanx.

01ericgruby on "Shared plugins folder"

$
0
0

Hello,

I'm developing a 'network' of sites in wordpress that have the same plugins, the same theme and the same content. This' network 'is connected to a single database, so, if I change the content of the 'parent site', all others are changed as well.

What I needed was that when I update the plugins of the 'parent site', the plugins from the 'child sites' update as well. Is there any way of the sites share the same plugins folder?

PS: Unsuccessfully, I tried using the instructions laid out here: https://codex.wordpress.org/Editing_wp-config.php

Thank you & Sorry for the bad English :)

andersonnarciso on "Category or Taxonomy marked, check automatically by default"

$
0
0

Hello guys!

Guys, there's some hook, hack or something that I add on functions that make a taxonomy or category is selected at the time of posting? Already come with chckbox marked to be..

Does anyone know?

keytastic on "Bypass password-protection for posts if user is logged in"

$
0
0

I'm trying to add a function that will make it so logged in users get to skip the password screen for any post that requires a password. My function seems to work for individual posts, but when on the home page it prevents additional posts from appearing.

function bypass_password_form( $output ) {
  if ( is_user_logged_in() ) {
    return apply_filters( 'the_content', get_page( get_the_ID() )->post_content );
  }
  // Or return the output as normal
  return $output;
}
add_filter('the_password_form','bypass_password_form');
Viewing all 8245 articles
Browse latest View live




Latest Images