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

mdgross on "WP_CONTENT_URL and TinyMCE"

$
0
0

We have defined the following in wp-config.php

define('WP_CONTENT_DIR', '/var/www/vhosts/cdn.domain.com/wp-content');
define('WP_CONTENT_URL', 'http://cdn.domain.com/wp-content');

We have also created a custom TinyMCE button

add_filter('mce_external_plugins', array($this, 'add_tinymce_plugin'));
add_filter('mce_buttons', array($this, 'register_tinymce_button' ));

The button is appearing but fails when clicked. According to console:

Error: Permission denied to access property "tinymce"
tinymce = tinyMCE = parentWin.tinymce;

I believe this is happening because WordPress is being served from http://www.domain.com but the popup is being served from http://cdn.domain.com. It works perfectly without WP_CONTENT_URL and WP_CONTENT_DIR. Please advise.


vcgs on "Wordpress 4.2.1 pre_get_comments doesn't work after update"

$
0
0

I have this code working all time but, after updating to Wordpress 4.2.1, this doesn't work.

// return just the missing replies in the comment table
add_action( 'pre_get_comments', array( $this, 'return_missing_list' ) );
public function return_missing_list( $comments = array() ) {

    // bail on anything not admin
    if ( ! is_admin() )
        return;

    // only run this on the comments table
    $current_screen = get_current_screen();

    if( 'edit-comments' !== $current_screen->base )
        return;

    // check for query param
    if ( ! isset( $_GET['missing_reply'] ) )
        return;

    // now run action to show missing
    $comments->query_vars['meta_key']   = '_cnrt_missing';
    $comments->query_vars['meta_value'] = '1';
    $comments->query_vars['date_query'] = array(
                'after' => '10 months ago'
            );

    // Because at this point, the meta query has already been parsed,
    // we need to re-parse it to incorporate our changes
    $comments->meta_query->parse_query_vars( $comments->query_vars );
} // end missing_reply_list

Can you help me about please?

Thanks!

ViktorPontinen on ".htaccess rewrite to only let through REST API requests"

$
0
0

Hello,

Would like to have some tips or guidelines on how to rewrite my .htaccess.
Im building an website which will work as an API and CMS for a mobile app and would to pretty much make the whole front-end unaccessible, except for the API Requests.

I would like the .htaccess file to only let through REST HTTP requests to my API endpoints(http://example.com/wp-json/...) and redirect everything else to /wp-admin/. Also blocking all robots and crawlers would be a bonus.

Anyone who could assist?

toasterdroid on "[Plugin: Edit Flow] Availability form the front-end"

$
0
0

I'd like to add the ability to add comments on pages from the front-end. I thought about using jQuery to do so, but I couldn't get any actual links to the process as all the buttons only seem to output a hashtag. Any ideas? It's a site that's for a limited group, by the way, it's not for public use so it's okay for such things to be visible on the front-end. Thanks!

https://wordpress.org/plugins/edit-flow/

tibernatu on "Creating a script rungs a function on every post"

$
0
0

I am very new to wordpress and php but I have a website with a few thousand custom posts. Each post has an address associated with it. On the admin page for each post there is a button that says "Place Pin At Address". When I click this button it creates a pin and it now shows up on the map on my sites homepage.

The problem is that it is extremely time consuming to click this button for every single post. Is it possible to run a function that will place this pin automatically whenever a post is published? I could be wrong but I believe all of the google functions are in javascript rather than php. Does that matter? I tried doing something like:

add_action( 'publish_post', 'codeAddress()' );

but it doesn't work. codeAddress is just one of the functions in the google map javascript functions folders in the theme. Any help would be greatly appreciated!!

antowordp on "use of tag into wordpress"

$
0
0

Hi i'm trying to upload a svg map to my wordpress website.

I fixed all to be able to upload svg trough the media gallery but then when i try to write the tag into the page it won't recognize it. I can only use it embedding it into a tag... but i can't do that cause i need to work with some svg effect like hover, clicking and so on...

pretty much i would need a way to insert the whole code with the path and so on, into my page... how to do that?

xblink87 on "Visit plugin site"

$
0
0

Hi, is there anyway I can disable " visit plugin site" on the installed plugins page?

Thanks

amberjean7 on "PHP code error"

$
0
0

Hello,

I'm new to PHP. Can anyone help me with what needs to be changed in the following code? I get the following error when I put the code into a code checker:

PHP Syntax Check: Parse error: syntax error, unexpected 'id' (T_STRING), expecting ',' or ';' in your code on line 13

class DE {
  public function _get($username) {
    if(is_user_logged_in($username)){
      return ‘valid’;
    }
    return ‘invalid’;
  }
}
$e = new DE();
if(empty($e->checkinfo))
   $x = 0;
for($i = 0; $i < 10; $i++) {
   echo ‘<ul id=“,‘.$i.”>’;
   for($j = 0; $j < 10; $j++) {
   if($x == 0)
     break
   echo ‘<li id=“,’$j’.”>Menu Item’.$j.’</li>;
   }
   if($x != 0) {
     echo ‘</ul>’;
   }
}

gab81 on "WP Social Meta Working on pages but not posts"

$
0
0

hi all,

I have tried to get in touch with the author of https://wordpress.org/plugins/wp-social-meta/ a few times without luck... this plugin is quite neat, adds Social tags for Google, Facebook and Twitter and is small and neat.

The only problem is that from the dashboard side of things, it shows up in Pages (works perfect) but not Posts (not showing on Screen Options at the top), the actual wpsm.php file is very small...maybe some mega code expert has some spare time to have a look?

on my live blog Posts i end up with Empty OG Tags so they are added correctly on live pages, just not showing up in the "Edit Posts" so you have no way to fill those fields.

many thanks!
Gabrio

Serpentsoft on "Email field in comment box got a script after posted"

$
0
0

Hi there, i have some wordpress themes for 2 yrs, one of them had over 15,000 comments from spambot you know however, i decide to remove it and as curiosity i looked for email, URL and comment from (Quick Edit Comment) then i found the Email field has a script after it like

( becrusnqvsx@gmail.com/* <![CDATA[ */!function(){try{var t="currentScript"in document?document.currentScript:function(){for(var t=document.getElementsByTagName("script"),e=t.length;e--;)if(t[e].getAttribute("cf-hash"))return t[e]}();if(t&&t.previousSibling){var e,r,n,i,c=t.previousSibling,a=c.getAttribute("data-cfemail");if(a){for(e="",r=parseInt(a.substr(0,2),16),n=2;a.length-n;n+=2)i=parseInt(a.substr(n,2),16)^r,e+=String.fromCharCode(i);e=document.createTextNode(e),c.parentNode.replaceChild(e,c)}}}catch(u){}}();/* ]]> */ ),

i found all emails had this script, then after i removed all comments i tried to add a new comment and then look for new comment i found the same script added automatically after my email.

Is that a security issue in my site?? Thanks for your help.

ariapictures on "theme_location variable and if statement"

$
0
0

I am using Advanced Custom Fields plugin and it all works.

I am trying to have the person creating the page choose a custom menu through one of the fields and have that variable pass into the theme_location, but I cannot get it to work.

the theme works if it is hard coded as such

'theme_location' => 'about',
or
'theme_location' => 'bicycles',

none of the following worked.
'theme_location' => the_field('product_menu');
'theme_location' => 'the_field('product_menu');'
'theme_location' => $variable, (yes the variable was pass via $variable = the_field('product_menu') and the variable echos the correct value.
'theme_location' => '$variable',

I even tried:

if ($variable == "about") {wp_nav_menu( array( 'theme_location' => 'about' ) );}
else if ($variable == "bicycle") {wp_nav_menu( array( 'theme_location' => 'bicycle') );}
else if ($variable == "shoes") {wp_nav_menu( array( 'theme_location' => 'shoes' ) );}

even tried this:

$v1 = "about";
$v2 = "bicycle";
$v3 = "shoes";
if ($variable == $v1) {wp_nav_menu( array( 'theme_location' => 'about' ) );}
else if ($variable == $v2) {wp_nav_menu( array( 'theme_location' => 'bicycle') );}
else if ($variable == $v3) {wp_nav_menu( array( 'theme_location' => 'shoes' ) );}

does not work, but the variables do, but the if statement is not recognizing anything.

what am I doing wrong???? [he asks while stands on the edge of a cliff]

it cannot be an ACF issue as the field is working... [he says under his breath]

Angelo Rocha on "Move publish metabox"

$
0
0

How to move publish metabox to down the edit field?

Howdy_McGee on "Undefined Index HTTP_HOST - canonical / nav-menu-template"

$
0
0

On of my popular WordPress installs is getting its debug.log blasted with two errors:

PHP Notice:  Undefined index: HTTP_HOST in /wp-includes/canonical.php on line 63
PHP Notice:  Undefined index: HTTP_HOST in /wp-includes/nav-menu-template.php on line 549

The following lines show:

canonical.php

$requested_url .= $_SERVER['HTTP_HOST'];

nav-menu-template

$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_root_relative_current );

This seems like an issue with WordPress generated by bots visiting the site. Do I make a ticket about this? I'm not entirely sure how to replicate the issue but it's becoming a problem as I usually like having my debug.log on incase a real issues occurs.

Anybody else have this issue / can replicate the issue?

JeroenReumkens on "Custom forgot password / new password page and url"

$
0
0

Hi,

I was wondering if someone could tell me if it is still possible to create a custom forgot password / create new password page at a different url? I see the core creates a cookie which is limited to the path '/wp-login.php'. Therefore I can't view the cookie and can't unset it after the user changed it's password. I am able to reset the password correctly by redirecting to my custom url with the get parameters (which is quite ugly I guess, and possible a security issue?), but then still I can't unset the cookie, which results in an error if I try to reset my password again, because it contains the old key.

Hope anyone knows the answer! Thanks :)

nirmal25990 on "Dispay Custom field data in Woo commerce order dashboard(all order)"

$
0
0

I added custom field check out page after order notes. Also display the custom field data on the admin order edition page(single order). I also want to display custom field data on Order Dashboard as in column.
Here is my code for custom code

/**
 * Add the field to the checkout
 */
add_action( 'woocommerce_after_order_notes', 'my_custom_checkout_field' );

function my_custom_checkout_field( $checkout ) {

    echo '<div id="my_custom_checkout_field"><h2>' . __('Reference Order') . '</h2>';

    woocommerce_form_field( 'my_field_name', array(
        'type'          => 'text',
        'class'         => array('my-field-class form-row-wide'),
        'label'         => __('Have a Reference Order Number Given By Friend'),
        'placeholder'   => __('Reference Order Number'),
        ), $checkout->get_value( 'my_field_name' ));

    echo '</div>';

}

/**
 * Update the order meta with field value
 */
add_action( 'woocommerce_checkout_update_order_meta', 'my_custom_checkout_field_update_order_meta' );

function my_custom_checkout_field_update_order_meta( $order_id ) {
    if ( ! empty( $_POST['my_field_name'] ) ) {
        update_post_meta( $order_id, 'Reference Order', sanitize_text_field( $_POST['my_field_name'] ) );
    }
}

/**
 * Display field value on the order edit page
 */
add_action( 'woocommerce_admin_order_data_after_billing_address', 'my_custom_checkout_field_display_admin_order_meta', 10, 1 );

function my_custom_checkout_field_display_admin_order_meta($order){
    echo '<p><strong>'.__('Reference Order').':</strong> ' . get_post_meta( $order->id, 'Reference Order', true ) . '</p>';
}

Plz help me ASAP. Thanks.


dgcov on "Adding a button without submitting the form using the options api"

$
0
0

I've registered my fields with add_settings_field('excluded_users', 'Users to exclude', 'teamsheet_arg_callback', 'teamsheet_plugin','teamsheet_plugin_section',array('excluded_users'));

In my callback I have:

<input id="excluded_users"
        name="teamsheet_plugin_options[excluded_users]"
        type="hidden"
        value="<?php echo $value;?>" />
      <input type='text' id='userBox' /><button onclick="javascript: addUser();">Add/Remove</button>
      <script>
        function addUser(){
        }
      </script>

I was expecting the "Add/Remove" button to run the AddUser() function which in turn would append (or remove) the user from the list contained in the "excluded_users" hidden input value.

Instead, the Options are submitted, a message comes up which says "Settings saved" and the options are committed to the database.

Is there any way to allow the onclick event to be processed without saving the options? The form has a submit button:

<input name="Submit" type="submit" value="<?php esc_attr_e('Save Changes'); ?>" />

How do I make sure that the form is only submitted on clicking this?

yatendra22 on "unwanted php adcash popup on my site"

$
0
0

dear sir,

my site http://www.sarkarijobsresult.com

that showing unwanted popup and it's address is "http://www.adcash.com/script/packcpm.php?r=36910"

this is a address that show when we click on my site any link and after some time this address redirect to another web address

so now please tell me some one how can face this problem

thank you

drezekiel on "Custom PHP script/page/function"

$
0
0

Hi , I have got some problem

How can i creat a custom php script?

for example , create a A.php and submit to B.php

how can i do this ? dont know how to make the post/get

can someone help me ~?

thanks a lot

Charlie on "TinyMCE Custom Button with AJAX"

$
0
0

I’m trying to create a simple proof-of-concept for a custom TinyMCE button in the WordPress post editor that, when clicked, will use AJAX to send “Hello World” to the server, then get “Hello World -- GOT IT” back from the server.

I’ve got the whole custom-TinyMCE-button part working just fine. And I’ve got the AJAX send/receive working fine. But the problem is that the AJAX send/receive isn’t happening when the user clicks the custom button -- it seems to happen as soon as the page loads!

The code below is what I pieced together from a bunch of examples I found on the Web (I’m not a JS programmer!). None of the examples were exactly what I was looking for, and that’s probably where the problem lies.

( function() {
    // This code belongs in /wp-includes/js/tinymce/plugins/beacon_clean/plugin.js
    tinymce.PluginManager.add( 'fb_test', function( editor, url ) {

        // Add a button
        editor.addButton( 'fb_test_button_key', {

            text: 'Test Button -',
            icon: false,
            onclick:
		jQuery(document).ready(function($) {

		    data = {
		    	action: 'aad_get_results',
		    	data_passed: 'Hello World'
		    };

		    $.post(ajaxurl, data, function (response) {
			alert('Got this from the server: ' + response);
		    });
		    return false;
		}) // jQuery.ready function

	} ); // editor.addButton
    } ); // pluginManager
} )(); // containing function

The custom button appears in the WordPress post editor just fine; the alert box appears with the modified test data from the server just fine. But the alert box appears as soon as the page loads -- it doesn’t wait for the user to click the custom button!

What do I need to change to make the AJAX call happen only when the user clicks the button?

Thanks!

goblendayi on "Using Anchor Link in wp_link_pages"

$
0
0

Hello!

I want users to be able to press 'Next Page' button in a single post to continue to the next page in the same post, pointing to a specific anchor, let's say #content.

<?php
    $defaults = array(
        'before'           => '<p>' . __( 'Pages:' ),
        'after'            => '</p>',
        'link_before'      => '',
        'link_after'       => '',
        'next_or_number'   => 'number',
        'separator'        => ' ',
        'nextpagelink'     => __( 'Next page' ),
        'previouspagelink' => __( 'Previous page' ),
        'pagelink'         => '%',
        'echo'             => 1
    );

        wp_link_pages( $defaults );

?>

These are the arguments I have.

Any help would be much appreciated. Have a nice day!

Viewing all 8245 articles
Browse latest View live




Latest Images