Forum Replies Created

Viewing 15 replies - 1 through 15 (of 49 total)
  • I too would love to know how to do this. I found an answer once a couple of weeks ago, but I can’t find it now.

    Thread Starter spartanv7

    (@praeix)

    Fixed my own problem and wrote a blog post on it detailing how to do it:

    How to Use Dynamic jQuery Form Fields in WPCF7 Email

    Thread Starter spartanv7

    (@praeix)

    RESOLVED!

    The link is here for anybody else wondering:

    CPT-onomies: Using Custom Post Types as Taxonomies

    Thread Starter spartanv7

    (@praeix)

    I switched the line:
    $posts = query_posts( $args );

    to:

    $posts = new WP_Query( $args );

    to see what the query was that is happening. Here it is below:

    SELECT esp_posts.* FROM esp_posts INNER JOIN esp_postmeta AS cpt_onomy_pm1 ON (esp_posts.ID = cpt_onomy_pm1.post_id AND cpt_onomy_pm1.meta_key = '_custom_post_type_onomies_relationship') WHERE 1=1 AND esp_posts.post_type = 'equipment' AND (esp_posts.post_status = 'publish' OR esp_posts.post_status = 'private') AND ( cpt_onomy_pm1.meta_value IN (51) ) GROUP BY esp_posts.ID ORDER BY esp_posts.ID ASC

    I’m using CPT_onomies to create the “locations” taxonomy from a custom post type called “locations” so that it is dynamic.

    Could this be causing the issue? I’m an idiot when it comes to breaking down SQL queries so I’m not sure exactly why this query wouldn’t be producing the results that I’m after.

    Thread Starter spartanv7

    (@praeix)

    Request for this to be moved to WP-Advanced please? It seems like it would be a better fit for there.

    Hey I’m late to the party here, so I bet this issue has either been resolved or you’ve moved on. I’m the guy who wrote the article, by the way. ??

    As Mika has said, it sounds as though you’ve done everything correctly up to step 3. What you’re saying you want to do is have sites like “example.com” point to a location at your website (ex: “url.exploringny.com”), but all the user sees is “example.com”, correct? That’s the whole point of domain mapping. First, you need to create the “url.exploringny.com” site. You’ll handle actually mapping the domain to that location in Step 5.

    Hope everything worked out!

    Thread Starter spartanv7

    (@praeix)

    Hmm, well I can get the option to update as it should (‘enabled’ when my theme is active and ‘disabled’ when something else is active). However, the value from the plugin isn’t correct and I think I know why. Since the plugins load before the theme, it doesn’t detect the correct value until you do a page refresh…

    So yeah, maybe this is truly impossible…

    Thread Starter spartanv7

    (@praeix)

    Right, but what I think Krishna’s functions are supposed to be doing (have no idea if they do or not, some people in his comments claim it works, others don’t and I’m starting to test it right now) is adding the hook for you to use.

    See the last line of his function wp_register_theme_deactivation_hook? It says add_action( 'switch_theme', $fn ); Wouldn’t that suffice since it’s executing the user-defined function to delete the option on ‘switch_theme’? switch_theme only detects when the theme switches, however, if the logic is followed correctly, then when it switches to something like Twenty Eleven, then it doesn’t matter because the option gets deleted and the hooks aren’t in Twenty Eleven, so the plugin conditional would show ‘false’. If you switch to another of your own theme with the hooks registered, then it would just start the process all over again, setting the options correctly.

    I’m just getting everything setup, so I’m going to test this out.

    I agree that this needs to be addressed in the core because it seems like a pretty basic functionality. How does code for the core have to get approved?

    Thread Starter spartanv7

    (@praeix)

    Here’s my logic on it:

    1. User enables your theme
    1. Create option for theme
    2. Set option to ‘enabled’/’true’/whatever
    • User downloads your plugin and activates
    • Plugin checks if theme is active
    1. If ‘yes’ – Do code for theme enabled
    2. If ‘no’ – Do nothing
    • User switches themes to ‘TwentyEleven’
    1. Before the switch, your theme switches option to ‘disabled’ or even better, deletes the option altogether
    • User switches back to your theme – start over at step 1
    Thread Starter spartanv7

    (@praeix)

    Yeah I just happened to see that Krishna’s post is from 2011 though. Here’s the link.

    Activation / Deactivation Hook For WordPress Theme

    Thread Starter spartanv7

    (@praeix)

    It would be the deactivation of the theme that should trigger the deletion of the option (so as not to build up crappy data, but to also serve as a reliable trigger to remove the option when your theme no longer exists), but as you stated, there is no deactivation hook or anything.

    So I found this https://core.trac.www.ads-software.com/ticket/7795.

    Krishna claims to have solved it, but I can’t seem to wrap my mind around the logic of the deactivation hook. Could be sleep-deprivation too LOL.

    Thread Starter spartanv7

    (@praeix)

    @esmi – Sorry there’s a flaw in the logic here. If you enable a theme like TwentyEleven, it still keeps the option value where it was set. I need to have a method for deleting the option on de-activation…

    Thread Starter spartanv7

    (@praeix)

    Sure! It’s only a few lines, but basically this is what I do in my admin.php file that spools together the theme admin interface.

    function fmg_constants() {
       // Add the theme option for use in plugins
       if ( !get_option( 'fmg_theme' ) ) {
           // Set the option
           if ( function_exists( 'add_option' ) ) add_option( 'fmg_theme', 'enabled' );
       } else {
           // Update the option
           update_option( 'fmg_theme', 'enabled' );
       }
    }

    Then in the plugin, I just check to see if it can pull in the option value.

    $option = get_option( 'fmg_theme' );
    if ( !empty( $option ) && $option == 'enabled' ) {
        // Stuff to do if it's enabled
    } else {
        // Stuff to do if it doesn't exist or doesn't match 'enabled'
    }
    Thread Starter spartanv7

    (@praeix)

    resolved

    Thread Starter spartanv7

    (@praeix)

    @esmi – Thanks for the response. This is very close to what I needed, but ultimately I’m using child themes so the name could change to whatever the user wanted…

    I instead decided to use add_option and get_option and it worked like a charm.

    Again thanks for your response!

Viewing 15 replies - 1 through 15 (of 49 total)