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

Pt on "Prevent   characters from getting removed by the visual editor"

$
0
0

I'm a graphic designer and want my   (non-breaking space) characters to stay where I bloody-well put them without the visual editor stripping them out again. If you're a typography dick like me, this is handy to make two or more specific words wrap together rather than breaking at the spaces.

For example, if you want "South Australia" not to break in an address.

So, I wrote added a simple shortcode via my child-theme's functions.php:

//[nbsp] shortcode
function nbsp_shortcode( $atts, $content = null ) {
	$content = '&nbsp';
	return $content;
}

add_shortcode( 'nbsp', 'nbsp_shortcode' );

Then I just use:
[nbsp]
Instead of:
 

Hope this helps someone.

Pt.


dmgcom on "Custom "remember me" box css not showing in Firefox."

$
0
0

Hi folks,

Newb here. I've set some custom css for my wp-login page. It looks fine in Chrome and Safari, but for some reason my css for the "remember me" check box is not showing up in firefox. I just get the standard, unstyled box. Any idea?

Here is a screencap of the styled check boxes as displayed by all three browsers:
http://upurs.us/view/72272

And here is the code affecting the box:

#login input[type=checkbox]:checked:before {
color: #ffffff;
}

#login label[for=rememberme] {
color: #ffffff;
color: rgba(255, 255, 255, 0.6);
}

#login input[type=checkbox] {
-webkit-box-shadow: none;
box-shadow: none;
background-color: #0a0a0a;
background-color: rgba(10, 10, 10, 0.65);
border-color: #ffffff;
border-color: rgba(255, 255, 255, 0.25);
border-radius: 2px;
}

Thank you for any help.

benoitf92 on "How to add checkbox in existing settings page"

$
0
0

Hi,

I'm trying to ad a checkbox to activate easily my maintenance page plugin.

I'm trying to put it in Settings -General page.

I have writted the following code:

function maintenance_options()
	{
		add_settings_section("maintenance_section", "Maintenance Options", "maintenance_options_content", "general");
		add_settings_field("maintenance_field", "Activate Maintenance Mode", "maintenance_form_element", "general", "maintenance_section");
		register_setting("maintenance_section", "maintenance_field");
	}

	function maintenance_options_content()
	{
		echo "Maintenance settings section";
	}

    function maintenance_form_element()
    {
        ?>
            <input type="checkbox" id="maintenance_field" name="maintenance_field" value="1" ' . checked(1, get_option('maintenance_field'), false) . '/> Checked to activate maintenance mode
        <?php
    }

    add_action("admin_init", "maintenance_options");

But When I checked it and save saettings this is not saved.

How can I realy add my new settings into this page ?

Carlsaint on "List all posts from a specific post status"

$
0
0

Hello, i've searched and searched and I cannot find a working solution to this:

I have some posts in a custom post status: "expired". I want them to continue in this post status, that is hidden from the main page, but i want to have another page where I can list them.

So I need to list all the post that are in the "expired" post status in a page, so they can be consulted by the visitors from my website.

Can someone help?

Thanks in advance.

nkpryor on "Classified Ads Website - Need code that'll prevent posts with "bad words""

$
0
0

So I use the "PreimumPress" Classifieds Blue child theme, and the code I have below will check if there is a “bad word” entered into the Keywords input/field and alerts the user about it once they click on the Save Listing button. The problem though is that it ONLY alerts the user when there is just ONE of the specified “bad words” in that field. It won’t trigger the alert when the “bad word” is found within a whole sentence. So I need help with two things…

– Can anyone help me tweak this code so that it will trigger the alert when the “bad word” is found ANYWHERE within that field, even if there are other words.
– Can anyone help me have this “alert” happen when the specified “bad words” are in ANY field, not just the “keywords” field.

*For reference, my website is http://www.lakomai.com

THANKS!!

<script>
jQuery(function() {
jQuery("#MainSaveBtn").on("click",function() {
    var name = jQuery("input:text[name='custom[post_tags]']").val();
        var badwords = ["word1", "word2", "bad word3"];

        if(jQuery.inArray(name, badwords) !==-1)
            {
                alert("Your Listing Contains Bad Words, Please Remove Them Before Proceeding");
                return false;
            }
});
});
</script>

MyThirdEye on "The best way to get content from other plugins?"

$
0
0

Hey guys,

My issue is that my plugin uses regex to search through the page content from WP POST and if it finds my plugin's code, then it will load in the scripts necessary, if it doesn't find my plugin's code, then it wont load the scripts. I feel this is the right way to do things because then the user's aren't boggled down with unnecessary files.

However, the problem arises with a few plugins ( mainly builders, Divi builder for example ) that do weird stuff to the content, and my plugin isn't able to detect anything in the regex function. I'm wondering if there is a better way to see if my plugin is within the page, or if I can somehow get the content of the page before certain plugins begin to alter it?

Would I have to dig into to the Divi code and see what they're doing or is there a better method?

Thanks in advanced!

nugs on "Basic Concepts of WP Plugins"

$
0
0

Hi guys,

First i want to apologize for the post, it truly is my last resort. I have searched high and low and i suspect i am searching for the wrong information cause it seems to not exist. Here is my dilemma:

I have a web app fully built and functional. My task now is to build a matching WP Plugin with much of the same functionality as my app. This is my first plugin. I understand that there are hooks i have to tap into to perform certain actions, like building menus or rending pages within the admin area. I have progressed nicely, hooking into the menu actions and building out the navigation of our plugin. One particular concept of redirection to other app pages is what i am struggling with.

So my app has a typical account login section. You need to be logged in to access various features. Typically there would be account page that would redirect you to a login page if you are not logged in.

When i was building out the menu items i understand the concept of hooking into the 'admin_menu' hook and providing the function that will render the page:

add_action( 'admin_menu', 'teb_engine_main_menu' );

...

add_menu_page(
'tebBooking',
'tebBooking',
'manage_options',
'mainmenu_slug_0',
'render_teb_main_page',
$icon_url);

...

function render_teb_main_page() {
   if ( !current_user_can( 'manage_options' ) )  {
      wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
   }

   require('teb_main_page_wrapper.php');
}

But this scenario is different. From code i need to load the appropriate page for the plugin - either a login page or the account page if they are authenticated already.

Can someone please briefly explain to me that basic concept of redirecting to certain pages within a plugin that is NOT related to any menu items of the plugin. Perhaps some example code to show me how this works would be great.

At a minimum can you please tell me if i am chasing something that does not exist and my understanding of this is not correct?

TIA
Nugs

Taro on "Search result based on menu category"

$
0
0

Hi All,

i'm looking for two pieces of code that can help me with the following:

I got posts and pages with a custom menu. These posts/pages got a custom template activated. The templates contains the menu for the specific posts and pages. This way i can order pages/posts in two different categories.

Now i like to change the search function; the search output should be based on the active custom menu category.

I named menu 1: Benelux and menu 2: International

1: First peace of code needs to be for the searchform.php
The code should look at the current active menu(category) and the search result should be based on the active menu.

If the menu is for example "Benelux" then the search result should only display pages/posts from the custom taxonomy that i made <input type="hidden" name="location" value="benelux" />
Or if the active menu is "International" then display pages/posts from the custom taxonomy <input type="hidden" name="location" value="international" />

I found the following code to get the menu category...not sure if this is useful..

(wp_nav_menu( array(
    'menu' => 'benelux'
) )

2: Second peace of code is needed for the search.php (header).
Because if the output should work correctly than we also need to change the menu for this search result page. Default the search.php uses the main menu.

So the following code needs to see if the pages/post contain taxonomy benelux or international and change the menu accordingly.

It would just be really awesome if this is possible.

Greatings,
Taro


guylancaster on "loading a file in php /wordpress"

$
0
0

Loading a flat file usually works on my dev WordPress and doesn't work right now on my live build - not good !

Here is my code. Can anyone suggest a bullet-proof version, please?
Permissions have been set to 755 so its not that.

if (is_admin()) $fl =  "../wp-content/plugins/carers/data/m.csv" ;
else $fl  =  "wp-content/plugins/carers/data/m.csv" ;
$handle = fopen($fl,"r");
$fileContents	= fread($handle, filesize($fl));
fclose($handle);

Tried get_site_url() to build a url for the file ... and a wp function that did a fopen and if that didn't work a curl ...

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.

darylblyth on "Variation Drop Down Box Under Product Title"

infocse on "Intersection of categories in automatic latest content (MailPoet)"

$
0
0

Hello, what I'd like to do is to put in some way an intersection/union of
categories in categories and tags area of the "automatic latest content options" (MailPoet).
This to send in mail only those products that are in two or more categories:

Ex.

Category A:
product 1, product 2, product 3

Category B:
product 6, product 2, product 4

In the email I will see just the product 2

could I make this?

Thank you

https://wordpress.org/plugins/wysija-newsletters/

redrop on "Chained select with jquery"

$
0
0

I am trying to get this tutorial to work in WordPress. I am not able to get it to update the second drop down box. how-to-create-chained-select-with-php-and-jquery/ Getting error Undefined index: id For now I am just running it in my header file and the other two files are in my theme folder. One person on there recommended changing the line to point to "http://mysite.com/wp-content/themes/my-theme-name/select_type.php" and that didn't work.

lazybatman on "Same sessions in two different installs."

$
0
0

I have two websites. i have created one database for both the sites so that when user registers into website one he can also use that login id for my second website. i have implemented that successfully. now i want to share sessions for example. when one user logs in to 1st website and when he goes to the 2nd website he should not have to login again. he should be already be logged into that website.

this are the two webiste i want to implement this.
this is the 1st website

This is the 2nd website

herculesnetwork on "how to write the output of this function in field 'tags' on post-edit"

$
0
0

how to write the output of this function in field 'tags' on post-edit the dasboard the worpress?

$input = array("neo", "Morpheus", "Trinity", "Cypher", "Tank");
$rand_keys = array_rand($input, 2);
$mixnames = $input[$rand_keys[1]];

Thanks to all.


airodumps on "how to remove short description"

$
0
0

hello i want ask how to remove short description on woocommercee, and use full description but with limit such 20 character maybe, is there plugin or should modify the code thanks.

msummers on "use an include in functions.php?"

$
0
0

Can I use an include in my functions.php file? This would really let me modularize some of my code if I can.

Ethan Jinks O'Sullivan on "Plugin options page: grouping checkboxes"

$
0
0

I've been using the WordPress Option Page Generator by Jeremy Hixon to help give me a head start with my plugin's option page. I've laid out four different types of checkboxes which the source code can be found here:

https://gist.github.com/factmaven/3896a3aac3888aa5bcddae48d9da5238

However, I'd like to add additional checkboxes in each of the four section that I've made, like so:

http://i.stack.imgur.com/jlxOT.jpg

Based on the generator, it looks like I would need to add another add_settings_field and another callback function to add more checkboxes; but that looks more tedious than I'd imagine just to add more checkboxes under each section. Is it possible to add additional checkboxes underneath the add_settings_field that I've already created? For example:

public function personal_options_0_callback() {
    printf(
        '<input type="checkbox" name="profile_settings_option_name[personal_options_0]" id="personal_options_0" value="personal_options_0" %s> <label for="personal_options_0"> Visual Editor</label>',
        ( isset( $this->profile_settings_options['personal_options_0'] ) && $this->profile_settings_options['personal_options_0'] === 'personal_options_0' ) ? 'checked' : ''
    );
    printf(
        '<input type="checkbox" name="profile_settings_option_name[personal_options_1]" id="personal_options_1" value="personal_options_1" %s> <label for="personal_options_1"> Admin Color Scheme</label>',
        ( isset( $this->profile_settings_options['personal_options_1'] ) && $this->profile_settings_options['personal_options_1'] === 'personal_options_1' ) ? 'checked' : ''
    );
}

Any help or guidance is appreciated. I've never made a plugin options page before, so if there is a simpler way of doing this, I am also open to your recommendation.

If you're on the WordPress Stack Exchange, I've also made the topic there if it's better to respond there:

https://wordpress.stackexchange.com/questions/235267/plugin-options-page-grouping-checkboxes

hafizfaheemmunir1404 on "Product category links required without images"

$
0
0

Hi,

I have some product categories and I want to show/display only name as links(without images) of product- categories. And I want to show on different pages....

Example:
Product-Category A(with image), Product-Category B(with images)

I want to show ... Product-Category A
Product-Category B
without images ... Kindly reply me ... Advanced thanks :)

Yon V on "Need help stop Hacking"

$
0
0

Hi,
In the last 2 weeks I have encountered two major hacking issues that I did not figure out how to solve:

1. In Google Search Console (Formerly Google Webmaster tools) I get messages about thousands of scan errors of pages that are clearly spam and return 504 and 503 response codes. It's like someone is creating thousands of spam urls that cause the traffic usage to my website increase to crazy levels of more than 30Gb a month! This also cause my website to crush.

2. The index page title and description changes to some gibberish in Chinese.

I would appreciate any help!
Thanks,
Yon.

Viewing all 8245 articles
Browse latest View live




Latest Images