Viewing 7 replies - 16 through 22 (of 22 total)
  • The shortcode does it. The menu item doesnt – and it can’t do that.

    How have you got the shortcode added? Again, we don’t need to see the code for the actioan function but we need to know how you are actually adding it to the system now.

    Also, take a look at the codex page for add_shortcode() as that will give you a lot more information about what you need to do to get that working.

    Thread Starter joethall

    (@joethall)

    Previously “The shortcode does it. The menu item doesnt – and it can’t do that” and I guess that pretty much says it all. If the menu just can’t “do that” then I’m not sure where to turn. The existing shortcode configuration seems to work – my PHP plugin code is executed and the redirect to the generated URL actually happens.

    The problem is that my client wants to know why it takes two clicks to make it happen. Thus, we have been looking for a way to configure the menu item to trigger the plugin – but this seems not to be possible.

    I am not familiar with WordPress as a web site host. Is there some other web page construct that I could be using. For example, is there a button that could do the job? The menu item was just the way that my client’s WordPress solution was implemented. I don’t think that there is a strong need to use only a menu item.

    In forums such as this, is there a protocol for us to communicate directly. I could give you more detailed information outside of a public forum.

    The shortcode is what does the work, so you will need to modify the function that the shortcode is calling to make it call the function directly.

    As you’ve stated, you can’t show code on here, so that leaves us in a bit of a bind. The best that anyone here can do is guess how it’s set up as we have got no way to see anything more than what we’ve got here now. ??

    But as I’ve said before as well, we don’t need to see the code for your clients function – just how it’s implemented. Again, without knowing what we’re working with, that just makes it so much more difficult from our end.

    BUT… with your particular problem, I’d suggest that the best way would be to look at JavaScript, and setting up an AJAX call to the actual function that gets the URL from your WordPress system and then does a browser redirect to that URL. Have a look here for details on how to make it work. You will need to know PHP, JavaScript and have a bit of an idea about how WordPress works, but that’s about the only way that I can see your issue working with a single click to a menu item – and that’s not a WordPress restriction, it’s a client/server restriction that any CMS would have.

    And lastly, I’m sorry but this is how the support is done. We’ve all volunteers here, so we don’t want to have emails, phone calls, etc at any time of the day. We help out here when we can. On top of that, it’s pretty frowned up on by the forum moderators so it’s best to stay on here. ??

    Thread Starter joethall

    (@joethall)

    OK, let’s see if the following will do a better job of explaining the problem. Please go to https://realestatedaily-news.com and note the main menu at the very top of the screen that starts with HOME and ends on the right with SUBSCRIBE. Login by scrolling down on the right side and use catacaustic and catac123. After completing the login there will be a new menu item at the far right of the menu – SEARCH COMPS.

    Click on SEARCH COMPS menu item and a new page will come up that has a link also called “Search Comps”. Click on this Search Comps link and up will come the Search Comps page. This is as far as you need to go.

    Please go back and try this sequence a couple of times. Note that all I am asking for is for the original first click on the SEARCH COMPS menu item to jump all the way to SEARCH COMPS. In other words, for the main menu click to run the shortcode REDC which will generate a URL string and redirect to it.

    NOTE: The shortcode called REDC is written in PHP and does some security tasks while building the text of the URL. So, all the PHP does is generate a string that is redirected to in order to in order to get the the final Search Comps page.

    I hope this helps!

    I do get what you are looking for. The problem is that without knowing how it’s been built now and no idea of what the requirements ra for your custum function, there’s no possible way for anyone here to say “here, this is how to make it work”.

    As a guide… You’ll need to find where the shortcode is being created, and that’s uisng the add_shortcode() function. That will point you to the function that displays the link. When you find that function yu can change it to display the information from your custom function instead of displaying a link to the URL.

    Unless you can do that yourself, we can’t help you. We don’t know what code you have working to make that shortcode or the page, and we don’t know what needs to be passed to your custom function to do what it needs to do. Without knowing all of that, we are all pretty much blind and guessing how things should work.

    And I’m not saying that it can’t be done, because seeing that, I’m about 99% sure that what you want is possible. It just needs to be done in a different way than what it is now

    As an analogy, this is basically the same as taking your car to the mechanic and having it go like this..

    You: I need you to fix my car, the engine isn’t working like I want it to.
    Mechanic: OK, lets have a look and see what the problem is.
    You: No, I can’t show you the car, just fix it.
    Mechanic:

    If what I’m saying in regards to looking through your sites code doesn’t make much snese then you really need to consider hiring someone that can do it for you as there i srealyl nothing else that anyone on the support forums can do apart form point yu to some documentation for the WordPress functions, and hope that you can programm it yourself

    Thread Starter joethall

    (@joethall)

    Here is the PHP shortcode:

    <?php
    /*
    Plugin Name: REDCportal
    Description: Prepare key for and redirect to a specific URL and display a comp
    Version: 1.0
    Date: 25 September 2014
    Author: Joe T. Hall
    */
    
    /*
    	Copyright 2014 JTH Software Enterprises (email: [email protected])
    */
    
    function REDCportal($atts, $content = null)
    	{
    	  $my_atts = shortcode_atts( array(
    	        'url' => '',
    			'text' => '',
    			'id' => '')
    			, $atts );
    	  $my_atts_text = $my_atts['text'];
    	  $my_atts_id   = $my_atts['id'];
    	  $my_atts_url  = $my_atts['url'];
    	/*
    	What goes here is PHP string processing that builds a URL that
    	includes various security features and would look
    	something like this:
    
    	    $my_return = 'https://www.mysite.com?id=myparams';
    
    	*/
    	  return $my_return;
    	}
    
    	add_shortcode( 'REDC', 'REDCportal' );

    The processing that builds $myReturn should not be relevant to this discussion. It is just string manipulation there are no system components.

    So, I believe I have divulged everything that is important to this conversation. Yes, I wrote the PHP shortcode REDC myself and it is above.

    My client’s site installed and activated the shortcode called REDC. My client’s site also created the main menu item Search Comps and directed it to open a page that had the shortcode syntax on it – [REDC]. When the visitor clicks on this second page link the shortcode function is executed. This is what you see when you run the instructions given previously.

    How can all of this be reconfigured such that a visitor to my client’s site only has to click on the menu item Search Comps?

    Yes, the car is not working as I would want but it is also not relevant what color it happens to be painted.

    What you’ve given there does give a bit more insight.

    You do know that you’re trying to display a remote page on your site? To do that you need to get the content from the page and output it in your page. But be aware that this may not work correctly if they are returning a complete web page instead of the the inner HTML content.

    So, you’ve got two options.

    First, display the code from the remote site as part of your page.

    Something like this… (note tested, so you’ll need to test all this yourself)

    $html = file_get_contents ($my_url);
    return $html;

    This assumes that your server allows file_get_contents() to fetch remote URL’s. If it doesn’t there’s many other things that you can do (CURL is about the best example).

    You’d return that HTML content instead of the link.

    Second option is the use an iframe to contain the remote page. You’d do this if it’s a complete page and needs to work by itself, which seeing your site I think that it does. so, you’d want someting ike this.

    return '<iframe src="' . $my_url . '"></iframe>';

Viewing 7 replies - 16 through 22 (of 22 total)
  • The topic ‘Direct plugin invocation from main menu item’ is closed to new replies.