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

Marcin on "WordPress on GIT"

$
0
0

Hi,
is it possible to use Git with Wordpress? Do you know any good tutorial described step by step?

I did it this way:
I installed the wordress on server i.e. 192.168.0.123.

Then I copied all files from 192.168.0.123 to my local folder and I created a project in Netbeans from Existing Source(my PC). Any changes in files are uploaded to server 192.168.0.123 straight a way.

After all I pushed project to WordPress Repository.

Another developer Cloned the project from repository into his PC and it is connected to WP database located on 192.168.0.123(to have the same post, plugins setting and so on). So we use the same database.

It works but:
If developer B makes some changes they are imedietly uploaded into 192.168.0.123. So in practice Developer B overwrite files of developer A and vice wersa. It's like skipping a GIT.

I need some help with it.
Regards,
Marcin


Mike_Oberdick on "Display Thumbnail from Child Post in Hierarchy"

$
0
0

I have a hierarchical taxonomy that is called album. It is structured as such: Paintings->2014->Flowers. Eventually "Paintings" will have several years (i.e. 2013, 2012). I have a page where all of the children are listed. I'd like show a thumbnail for each of those folders from a child descendant. So for example, using Paintings->2014->Flowers, I'd like to get a thumbnail from Flowers posts to show as a thumbnail for the 2014 folder. As you can see now it's not working properly.

Here is my taxonomy-album.php file.

Cliff on "How to loop ads until end of page"

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

FelixHansar on "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!

mstdmstd on "js-methods with prefix specified"

$
0
0

Hi all,
I have wordpress plugin with js-file attached for js functions.
I want to escape possible error of having js functions with the same name as js functions pf other developers so I use some prefix like "nsnpas_" in functions name and inputs name.
This prefix I define as php constant

define( 'nsnPluginPrefix', 'nsnpas_' );

and use it like :

<script type="text/javascript" language="JavaScript">
    /*<![CDATA[*/
    ...
    var <?php echo nsnPluginPrefix ?>obj_productsAjaxSearchBox = new <?php echo nsnPluginPrefix ?>productsAjaxSearchBox(  { nsnPluginPrefix : 'nsnpas_', ...   },
        use_in_search_array, autocomplete_save_options_as_array );  // That is object's ref to my js functions
    ...
            <input value="<?php echo get_search_query() ?>" name="input_<?php echo nsnPluginPrefix ?>search" id="input_<?php echo nsnPluginPrefix ?>search" class=""  placeholder="Type search" />&nbsp;
   ...

            <img src="<?php echo $plugin_url ?>images/arrow-down.png" alt="Open Options" title="<?php echo esc_html__("Open Options") ?> style="cursor: pointer;"  onclick="javascript:<?php echo nsnPluginPrefix ?>obj_productsAjaxSearchBox.openOptions();">  <!-- margin-left: 10px; width: 16px;height: 16px; -->

and in my js file ti which I set nsnPluginPrefix as:

...

var this_m_nsnPluginPrefix;

function nsnpas_productsAjaxSearchBox(Params, use_in_search_array, autocomplete_save_options_as_array) {  // constructor of backend artist's editor - set all params from server
    selfproductsAjaxSearchBox = this;
    this_m_nsnPluginPrefix = Params.nsnPluginPrefix;
    this_plugin_url = Params.plugin_url;
    ...
}

nsnpas_productsAjaxSearchBox.prototype.openOptions = function () {
    $( "#span_"+this_m_nsnPluginPrefix+"openOptions").css("display","none")
    $( "#span_"+this_m_nsnPluginPrefix+"hideOptions").css("display","inline")
    $( "#div_"+this_m_nsnPluginPrefix+"ajaxSearchOptions").css("display","inline")
}

It works for me. but I have to write function's object as literal "nsnpas_". I mean If I need to change nsnPluginPrefix contant, I would have to change "nsnpas_" literal by hand in all js file.
If there is a way to generate this prefix programmatically in js file or can this be salved i some different way?

Thanks!

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?

[Moderator Note: No bumping, thank you.]

dwayne112 on "display 4 posts from one category on front page of word press site."

$
0
0

HI I am a noob- can anyone tell me how to display 4 posts from one category on front page of word press site. While on the dashboard -Pages- HomepageOne. I selected and added a category widget along with one category filter. On the front page it only shows one post. If I select 2 category in the filter it will display more that one post on the front page however I need just one category to display 4 posts.
Can anyone assist?

[continue with the original topic at https://wordpress.org/support/topic/how-to-display-multiple-posts-from-one-category-on-front-page?replies=1 ]


mitel on "Create new posts from external website."

$
0
0

I need to create new posts in an existing WP site using data returned from an external API call via a Cron job on the same server/domain as the WP site.
I can see that XML-RPC would be the way to go for this but I have not been able to find out how to also include tags and categories when creating the new posts.
Matching tags and categories are already present in the WP site.
So, I call an API and with the returned data I will format it ready for inserting into the wp_posts table. Part of the API data will also provide me with what categories the new post should be assigned so I need to include this with the new post creation function somehow.
Also, should I be concerned that the API may return in excess of 5,000 new posts?
Imagine you were importing library books from your local libraries API into your WP site as new posts and each had to be categorised appropriately, that's basically what I need to do. And this API call has to be run daily.

Any help much appreciated.

Guido on "Using sprintf in shortcode"

$
0
0

Hi,

I have a page-template that displays a form via a shortcode, I use this to display the form:

echo do_shortcode( '[my-form]' );

I want a text input field in backend so user can insert shortcode attributes (so user can rename form labels). My field is called 'attributes'.

I use this to display the shortcode in page-template, including inserted attributes.

$content = sprintf('[my-form %s]', esc_attr($instance['attributes']) );
if ( !empty( $instance['attributes'] ) ) {
	echo do_shortcode( $content );
}

Code works, but can I use a sprintf in this case?
Because it has nothing to do with a 'normal' text string.

Guido

rohin.grover on "Multiple values to same meta key"

$
0
0

I have fields in my theme and i am using wp user frontend and making a form to get input from users. i have a fields project gallery which can have multiple images now i using that field meta key in my form for single image its working but when uploading multiple images it only getting the value for the first image uploaded.
Please help.

Thanks in advance.

Mike_Oberdick on "Art Gallery using Custom Post Type and Custom Taxonomy"

$
0
0

I'm working on a website for an artist. I have created a CPT called "artwork" and custom taxonomies for the attributes of each piece of work. One of the custom taxonomies is "album" which supports a hierarchy so that a user can navigate through the gallery. It is working somewhat here if you click on "2014" and then "Flowers". What I'm missing is a thumbnail image for each folder that is pulled from the actual artwork (grandchild of parent term). Here is my code from the taxonomy-album.php file:

<?php get_header(); ?>

<div class="container clearfix">
		<header class="entry-title">
			<h1 class = "archive-title"><?php single_cat_title(); ?></h1>
		</header>

<h3 class = "category_description"><?php echo category_description(); ?> </h3>

<div class = "taxonomy_thumbnails">

<?php

$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); // get current term

$parent = get_term($term->parent, get_query_var('taxonomy') ); // get parent term

$children = get_term_children($term->term_id, get_query_var('taxonomy')); // get children

if(($parent->term_id!="" && sizeof($children)>0)) {

// set the args for wp_list_categories

$args = array(
    'child_of' => $term->term_id,
    'taxonomy' => $term->taxonomy,
	'order' => DESC,
	'hide_empty' => 0,
	'hierarchical' => true,
	'depth'  => 1,
	'title_li' => ''
    );

wp_list_categories( $args );

}elseif(($parent->term_id!="") && (sizeof($children)==0)) {

?>

<div class = "archive_thumbnail_box">

<?php

	$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' );
	echo '<a href="' . $large_image_url[0] . '">';
	the_post_thumbnail( 'thumbnail' );

	echo '</a>';

?>

<span><?php echo get_the_title(); ?></span>

</div><!-- .archive_thumbnail_box -->

<?php

}elseif(($parent->term_id=="") && (sizeof($children)>0)) {

// set the args for wp_list_categories

$args = array(
    'child_of' => $term->term_id,
    'taxonomy' => $term->taxonomy,
	'order' => DESC,
	'hide_empty' => 0,
	'hierarchical' => true,
	'depth'  => 1,
	'title_li' => ''
    );

wp_list_categories( $args );

}

?>

</div> <!-- end of .taxonomy_thumbnails -->

</div> <!-- end of container -->

<?php get_footer(); ?>

Arnolddew on "Remove css/style from author role"

$
0
0

Hello,

I need a code snippet to remove css/style when a author is logged in.
I'm found an old code, but it breaks some elements of my theme and plugins:

get_currentuserinfo() ;
global $user_level;
if ($user_level > 3) {$hidefromuser="";
}
else {$hidefromuser="display: none";}
?>
<style>
.wp-media-buttons, #wp-admin-bar-comments, #wp-admin-bar-new-content, #wp-admin-bar-wpseo-menu, #traffic_light, #mceu_16, #mceu_17 {<?php echo $hidefromuser; ?>;}</style>

ArtissTheGeek on "Shortcode parameter form"

$
0
0

Does anybody know which characters can be used as wrappers for passing shortcode parameters. I know single and double quotes work, but what else?

Also, is there a way for the user to escape them? So, if they want to pass a text parameter which contains both single and double quotes, how would they go about this?

Thanks,
David.

Ciao121 on "Problem in custom "mu-plugins" plugin."

$
0
0

I'm trying to use this code in a file in mu-plugins.

<?php
function myfunction($user_login, $user) {
	$current_user = wp_get_current_user();
	$user_id = $current_user->ID;
	$display_name = $current_user->display_name;
	if ($user_id==5){
          //do something
	}
}
add_action('wp_login', 'myfunction', 10, 2);
?>

But it seems $user_id in not returning values...
Can somebody help?
Thank you


jpking72 on "Access Media Files From an External PHP Application"

$
0
0

I have a PHP based application that runs on the Google Maps API. Most of it is written in straight PHP and Javascript, but I want to use some sort of CMS or tool to upload images, because there will be large numbers of images and categories to go with those images. So I want a very robust interface for uploading images and I thought I would use Wordpress. So I want to use the "Media" portion of Wordpress to add/edit/delete images and then use some sort of Wordpress hook to add them to the page in the external application. Any insights as to the best way to do this?

levialanm on "setting not getting saved"

$
0
0

Hello,
I am trying to add a setting customization for a theme (modifying version of https://github.com/natejones/wpds. The database does not get updated for my new "slidetime" setting when I click on "Save & Publish". However, the Site Title (setting ID "blogname") setting does get saved. Any clue what I'm doing wrong? Here's the code I added to post-details.php. You can see some options commented out that I experimented with.

function wpds_NF_customize_register( $wp_customize ) {
  $section = 'NF_section'; // 'static_front_page'
  $wp_customize->add_section( $section , array(
		'title'      => __( 'NF Customization', 'mytheme' ),
		'priority'   => 30,
  ) );
  $slideTimeId = 'slidetime';

  add_option($slideTimeId, "7744");

  function slideTimeSanitizeCallback($val) {
	error_log("slideTimeSanitizeCallback " . $val);
//	update_option('slidetime', $val); // experiment to force update, but this causes infinite recursion
	return $val;
  }

  $wp_customize->add_setting( $slideTimeId , array(
    'default'     => get_option('slide_time'),
    //'transport'   => 'postMessage', // postMessage',//refresh',
	'type'        => 'option',//theme_mod', //option',
	'capability'  => 'manage_options', //edit_theme_options', //manage_options', // https://codex.wordpress.org/Roles_and_Capabilities#edit_theme_options
	'sanitize_callback' => 'slideTimeSanitizeCallback'
  ) );

  $wp_customize->add_control( $slideTimeId, array(
		'label'      => __( 'Slide Time' ),
		'section'    => $section,
		'settings'   => $slideTimeId
  ) );
}

add_action( 'customize_register', 'wpds_NF_customize_register' );

DocWarlock on "Website Hack"

$
0
0

Hacker manager to create an admin position for him/herself and I have found the user name over 50 times so far. Have tried to delete with a bulk action, but evidently I don't do it correctly. Suggestions?

netboy78 on "how to change link available on all post_content?"

$
0
0

how to change link on all post_content like :
domain.com/12345-ebook-guitar to domain.com/12345
domain.com/454545-ebook-piano to domain.com/454545
domain.com/78910-cook-book to domain.com/78910

how to remove anythng after domain.com/12345 remove---->-ebook-guitar

how to do this?

Please help me..

iamdanieljs on "Import users from non-wordpress database"

$
0
0

I have a custom-made script, running a bookingsystem. I would like to have all the clients at the bookingsystem, automatic imported to my wordpress site as normal users.
At the bookingsystem all users are registred with a username, email, frontname and lastname in a mysql database.
Does a plugin with that ability already exist? I have been searching for hours now, but without luck.

Viewing all 8245 articles
Browse latest View live




Latest Images