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

jumaru7 on "Change code from WordPress Admin directions"

0
0

Hello i dont know if this is the right category to post this but i have this code in a theme template

<div id="sidebannerp">
<a href="" target="_blank" title=""><img src="" /></a>
</div>

Its a simple styled container with an image and a link.

This is a form of banner and to change it everytime i have to upload the picture in the proper folder and then edit the href.

So i want to make it so that i will be able to change the href link in wordpress admin page instead of editing everytime the php file of the theme like how are settings of a theme where you alter the code from worpress admin panel.I know(or at least i think) that this isnt simple so i would like to know where i should start looking for to learn about how to do it (languages to learn e.t.c).Thanks.


Nozibulla on "Pull All image from a folder in a wordpress plugin"

0
0

I am working on a wordpress plugin and in that plugin i need to pull all image with .png extention from a folder which reside my plugin images folder. I am using the following code

foreach ( glob( plugin_dir_path(__FILE__ ) .'images/previews/*.png') as $img ) { echo $img.'<br>';
         echo '<img src="$img" alt="">';
        }

when i echo the $img it shows the entire path but when i use this path as the image source it doesnot show the image.It shows a broken image if i dont use the 'alt'. I have searched for it but cant find any solution on web which is working for me. But a raw php file with the same code is working just fine

jameswalkerovic on "need to change colour of author(admin) when posting in forums"

0
0

Hi,

My website has a built-in bbforum in it (bbpress) and i was wondering if there was a plugin that changes the admins and moderators usernames to a unique colour. different from what the normal users have
for example admin would be red
moderator would be blue
members would be green (default colour)
and banned users would be black or grey

exactly like a normal forum

is such thing possible?

WrdprsKN on "file won't format correctly"

0
0

I am getting the following error message on certain pages of a WordPress site I'm working on:

Strict Standards: Only variables should be passed by reference in /opt/bitnami/apache2/htdocs/wp-content/plugins/xf_integration/include/xf_replacement_comment_handler.php on line 287

What would cause this to display?

This is the code on line 287:

if($threadModel->canReplyToThread($thread, $forum, $errorKey = ''))

Thank you!

boybawang on "How to get current page URL regardless of permalink settings"

0
0

I'm familiar with get_permalink() to get the permalink URL, but I need to get the URL of the page regardless of the user having permalink settings or not. In other words, if they have the 'default' permalink settings, I would like that URL.

For example, suppose I have a page whose ID is 12345. The permalink URL might look something like this:

http://www.domain.com/some_page/

The 'default' URL might look like this:

http://www.domain.com/?page_id=12345.

Is there a WP specific function to obtain this URL? I'm familiar with $_SERVER['REQUEST_URI'] and $_SERVER['PHP_SELF'] , but was hoping for something WP specific.

Thanks

dan1989 on "Suspicious script Getting injected in my website's header again and again"

0
0

A suspicious script is getting injected on all my website again and again even after removing..!! Its on shared server.
Please check the screenshot :-

https://drive.google.com/file/d/0BxeA28xMdEqIaWxZYU5ObFdqZkE/view?usp=sharing

I kept on removing the the script from the header files , but not able to get the permanent solution ..

For reference please check the source code of other websites also ... same code is triggered to all website..as you can see in the screenshot,

website :- http://www.airconelevators.com
oxygymfitness.in

Any help would be appreciable .!
Thanks..!!

LuciferIAm on "Updating custom field when remote publishing."

0
0

So.

A service I use posts images on WordPress for me, simply by inserting <img src="<imgurl>"/>

What I've been struggling greatly to do is setup code so that when it does this, my code grabs the url, updates a meta field 'nelioefi_url' with said URL then strips the remaining image. Full disclosure I'm pretty much novice level for sure. I'm definetly guessing I'm missing a set of code to update the post so that it then has an ID to use, however I'm not sure the best way to go about this.

Side notes: _nelioefi_url() is correct, I've used it successfully with modifying other plugins but wasn't able to reach my desired outcome. The remove images also works.

add_action('xmlrpc_publish_post', 'nelioefi_update_url' );
    add_action('the_post', 'nelioefi_update_url');
    add_action('save_post', 'nelioefi_update_url');
    add_action('draft_to_publish', 'nelioefi_update_url');
    add_action('new_to_publish', 'nelioefi_update_url');
    add_action('pending_to_publish', 'nelioefi_update_url');
    add_action('future_to_publish', 'nelioefi_update_url');

    function grab_external_url($content) {
	global $post;
    $pattern = '|<img.*?src="([^"]*)".*?/?>|';
    $content = preg_match($pattern,$content,$matches);
    var_dump($matches);
    return $content;
    }
    add_filter('the_content','grab_external_url');

    function nelioefi_update_url( $post_id ) {
	global $post;
    $imgUrl = get_post_meta( $post->ID, 'grab_external_url', true );

	if ( $imgUrl!="" ) {
		update_post_meta( $post_id, _nelioefi_url(), $imgUrl );
	}

    }

    function remove_images( $content ) {
    $postOutput = preg_replace('/<img[^>]+./','', $content);
    return $postOutput;
    }
    add_filter( 'the_content', 'remove_images', 100 );

fourtytwo on "how to modify the PayPal transcript"

0
0

Hello Everyone!

I want to modify the transcript that we received from PayPal after a Complete order. In the following transcript under the description section , u can see the details of the product. Like name of the product , order no and size etc..

Blow is the content that Em talking about.

Description                     Unit price      Qty   Amount
Guardians of the Galaxy Jacket   $105.00 USD	   $105.00 USD

In the above code under the Description section , u can see the product name , Which is in this case Guardians of the Galaxy Jacket Here is the Screen so u guys can get the better view of the transcript..
Captured Screen

I want to remove (replace) that part with something like:

Order no 1245 or Article No: 4535

We do not want to appear the Product name in the transcript.

Thanks you for taking your time to read this.Any help Please :)


Bojan Denic on "Shortcode for user address"

0
0

I need shortcode for user address, city, contry(from user profile), I don't find solution for my problem.

This is my code:

function mojaadresa_func( $atts ){
$current_user = wp_get_current_user();
	return $current_user->user_address;
}
add_shortcode( 'kod_adresa', 'mojaadresa_func' );

Thanx

josullivan.c on "Where to place db_connect.php"

0
0

Hi there,

Quick question - I am pulling content to a child theme using my own DB, separate from the WP DB.

Is it safe to place my custom db_connect.php file in htdocs? ie. Is this folder readable via the Web?

Thanks in advance!

microtag on "Problem with orderby and Taxonomy"

0
0

I am querying the terms in a custom taxonomy i have with the following code:

<?php
    $term_id = 2;
    $taxonomy_name = 'rete';
    $termchildren = get_term_children( $term_id, $taxonomy_name );

      $args         = array(
      'child_of' => $termchildren->term_id,
      'orderby'  => 'id',
      'order'    => 'DESC'
      );

 $term = get_terms($taxonomy_name, $args);

    echo '<ul>';
    foreach ( $termchildren as $child ) {
        $term = get_term_by( 'id', $child, $taxonomy_name );
        echo '<li><a class="uno">' . $term->name . '</a></li>';

    }
    echo '</ul>';

  ?>

Works fine but do not order! The problem i have is that i would like to order it by title-order or something similar.

Can anyone suggest what i need to do? Thanks.

denizgezgin on "navigation buttons in the modal window"

0
0

Hello everyone,

I'm working on my dad's portfolio site, but there is something I cannot solve.

On my site, photos open in a modal window when clicked. Photos are portfolio post type. Since it will be a tiring experience to view a photo, then close the modal, then open the next photo, I must add navigation (prev/next) buttons into the modal window.
I added the following prev/next post links indicated in WP Codex, but of course they don't work in the modal window. What I need is simple actually: to be able to use next/prev between the photos, without leaving the modal window. And also to be able to use arrow keys for this, probably.

This is the code I added in the theme's "template-portfolio.php":
<?php previous_post_link('%link', 'PREV'); ?> | <?php next_post_link('%link', 'NEXT'); ?>

Plus, there are the portfolio tags at the top. Is it possible for the navigation to work only between the photos in the selected tag? At the moment, it works between the photos in "Tumu (All)".

Or is it not that simple, in fact?:) I tried several plugins, but none was directly compatible with the modal here, not that I expected them to be.

Can anybody help me on this, at least by pointing me in the right direction?

Thanks in advance!
Deniz

crovinca on "admin-ajax.php alternative?"

0
0

Hello,
I want to ask, is there a way to have ajax functionality without calling admin-ajax.php?
I have site with plugin that call admin-ajax.php to frontend, and admin-ajax.php is really make site slow... Because that plugin function is essential for my client site, it cant be change or uninstall it.

If there is really no way to change admin-ajax.php with other ajax script, can someone tell me how to speed it up? I really don't understand how the less than 10kb file can really slow to load, while the 180kb image in my client site is 4times faster to load..

any ideas?

Thanks!:)

masonify on "Is it Taxanomy' that I want to create for user categories"

0
0

New to wordpress, been using it 1 day, coming from a heavy Joomla background.

I want to be able to attach more information to users (via meta data), that's fine, i have those fields on the new user and profile pages, but some of the information needs a drop down list that I don't want to pre-define.

e.g.
having a drop down Mr. or Mrs. box.

I obviously don't want to hard code Mr. and Mrs., so I'd like a place to edit these in admin, also allowing the user to customize the list and add Dr. for instance or whatever else.

Is it taxanomy' that I want to define here?

Also, any examples of listing these custom taxanomy' in a listbox?

Cyberchicken on "inside wp_trim_excerpt"

0
0

I have a widget that lists some posts, and it uses get_the_excerpt(), which in turn uses wp_trim_excerpt() becasue wp_trim_excerpt() is registered by default at 'get_the_excerpt'.
Fine.

My posts are like:
<h1>Date first of march</h1><h2>Price 100$</h2>

wp_trim_excerpt() does strip away any html (fine, the reson is not to clip away any html tag), but this leaves the my post excerpt like:

Date first of marchPrice 100$

with two words stick together.
Now, I know this ain't a perfect world and I could live with it, but the customer noticed and I'm always curious.

So I decided to add a filter _before_ wp_trim_excerpt():

function forsailing2_excerpt_reformat($input) {
	$output = str_replace ( '><' , '> IAMAWHITESPACE <' , $input );
    trigger_error("forsailing2_excerpt_reformat<br>input: $input<br>output: $output<br>");
	return $output;
}
add_filter( 'get_the_excerpt', 'forsailing2_excerpt_reformat', 9);

This doesn't work: my filter is called one time for each excerpt shown but $input and $output are blank and the excerpts are displayed as if the filter was not there. I also tryed with priority 11 (I can see with debug bar the original filter mounted at priority 10).

FIRST QUESTION is: what did I get wrong (about priorities? parameters passing?)

I then tryed another way and deregistered wp_trim_excerpt() from 'get_the_excerpt' and register a similar function at the same place.

OK, I succedeed and obtained exactly what I wanted, BUT.

In the original wp_trim_excerpt() there's a line
$text = strip_shortcodes( $text );

SECOND QUESTION: Why is that? Is there any core developer to explain to me why stripping the shortcodes instead than elaborating? There might be a technical reason. performance?

I actually need the shortcodes to be elaborated not only in posts but also in excerpts, because the very first line contains some data taken from somewhere else.

I substituted the stripping with
$text = do_shortcode( $text );
and it worked just like I needed.

I also inserted
$text = str_replace ( '><' , '> <' , $text );
at the right point and that inserted the whitespace I needed.

I reached what I need, but feel uneasy because I duplicated a lot of code, changing only two lines, and basically overridden a core function of which I sould take care from now on.
THIRD QUESTION: Isn't there a better way to achieve this?
I feel like that if I could add my own filters _before_ wp_trim_excerpt() I would be alright and future proof.

Thank you for your time


jogospa on "No link on my picture with chrome"

0
0

I made a 3 columns to show the main picture of articles, on the cathegorie page, but in chrome i cant click on it, for the columns 2 and 3, to link to the articles.
It works well with mozzila and safari.

This is the link to the page : http://dinettemagazine.com/?cat=2

for my css it's:

.blog-wrap {
margin: 0 auto;
}

.blog-wrap #primary {
-webkit-column-count: 3; /* Chrome, Safari, Opera */
-moz-column-count: 3; /* Firefox */
column-count: 3;
-webkit-column-gap: 5px; /* Chrome, Safari, Opera */
-moz-column-gap: 5px; /* Firefox */
column-gap: 5px;

LuciferIAm on "Getting a plugin to activate when remote publishing"

0
0

the following works perfectly fine when updating a post / publishing a post manually. However the plugin wont activate when a post is published remotely. There is so little documentation on 'xmlrpc_publish_post' that I really have no idea what it is I'm doing wrong.

add_action('xmlrpc_publish_post', 'nelioefi_update_url' );
add_action('the_post', 'nelioefi_update_url' );
add_action('save_post', 'nelioefi_update_url' );
add_action('draft_to_publish', 'nelioefi_update_url' );
add_action('new_to_publish', 'nelioefi_update_url' );
add_action('pending_to_publish', 'nelioefi_update_url' );
add_action('future_to_publish', 'nelioefi_update_url' );

function nelioefi_update_url( $post_id ) {
// get the post object
$post = get_post( get_the_ID() );
// we need just the content
$content = $post->post_content;
// we need a expression to match things
$regex = '/src="([^"]*)"/';
// we want all matches
preg_match_all( $regex, $content, $matches );
// reversing the matches array
$matches = array_reverse($matches);

    $urlplz = print_r($matches[0][0], true);
    if ( $urlplz ) update_post_meta( $post_id, _nelioefi_url(), $urlplz );
    }

function remove_images( $content ) {
   $postOutput = preg_replace('/<img[^>]+./','', $content);
   return $postOutput;
}
add_filter( 'the_content', 'remove_images', 100 );

r2eq on "How to Add Widget to Post Meta Data?"

0
0

How do I insert a widget showing page views into the Post Meta data (under the title, where it says date/author/comment I'd like it to show the post views).

I am running the 2014 theme.

The plugin for the views is called Post Views Counter. Their support forum said,

"You would have to use a function inside your theme, inside a loop in archive or anywhere you want it to be displayed:

pvc_post_views( $post->ID );"

I'm not sure what they mean by that. I started looking up loops and meta data and am getting nowhere. Any help is appreciated. Keep in mind I'm not a programmer or anything.

The picture below shows what I'd like to do. Move the info displayed in the red arrow to the green arrow.

[IMG]https://cf.geekdo-images.com/images/pic2712066.jpg[/IMG]

zagreus on "Adding a new user to a blog"

0
0

I'm clearly very slow tonight. In my multisite environment, I want everyone to become a member of a specific blog. To do this, I have created a very small plugin which does this.

add_action('wpmu_new_user', 'mjt_join_add_user_to_community');
function mjt_join_add_user_to_community() {
  $blog_id = 3;
  $role = 'administrator';
  add_user_to_blog($blog_id, $user_id, $role);
}

The user gets created however they dont get added to the blog.... Am I missing something?

jmcginnsher1 on "Form submissions wont save to database / display in WP dashboard"

0
0

I decided I wanted to build a simple plugin for a contact form for future projects that I will work on. The purpose of the plugin was to send an email containing the data to the admins email address, save form submissions in the database and display them in WP dashboard.

So far the following is working:

1. Plugin is appearing in plugins section of WP dashboard

2. Once the plugin is activated - a new menu item for displaying form responses is added to the WP dashboard and the form displays on the website itself.

3. Before adding the JQuery validation / Ajax - the form was submitting to the database / WP dashboard and sending and email to the admins email address.
However this isn't working anymore for some reason.

4. If you try to submit the form without filling in all the fields, validation messages appear until all fields have been filled in.

5. An ajax request shows a success / error message when the message has been sent / not sent.

The only issue and the big issue that I am having at the minute is saving the data from the form into the database, displaying the data in the WP dashboard and sending an email to the admin.

If someone could help me get this working it would be much appreciated. Also I am aware of the security issues around building your own plugins - could someone let me know if I have correctly sanitized all data etc.

I have included all code in the pastebin links below.

* Code for plugin *

* Code for JQuery validation / Ajax *

* Code for form *

* Code for displaying form submissions *

Thanks for any help in advance.

Viewing all 8245 articles
Browse latest View live




Latest Images