WordPress.org

Ready to get started?Download WordPress

Forums

Front-end Editor
[resolved] Wrap editable_post in an if function? (9 posts)

  1. iSimone
    Member
    Posted 3 years ago #

    Hey scribu, thanks for making something like this happen. I really love what someone with actual development skills could do with this (not me obviously).

    I got two questions:

    1) I would like to use the front-end plugin on custom fields and other stuff. So adding something like this is the way to go: <?php editable_post_meta(get_the_ID(), 'my_key', 'textarea'); ?> Is there something like if functions exists, so I can make sure that my theme will still work after desactivation of the plugin?

    2) After editable_option has been included in the plugin, what of the dev guide do I need to have a look at (http://scribu.net/wordpress/front-end-editor/developer-guide.html)?

    Cheers, have a great Evening

  2. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    1) Is there something like if functions exists, so I can make sure that my theme will still work after desactivation of the plugin?

    You can do something like this:

    <?php
    if ( function_exists('editable_post_meta') ) {
      editable_post_meta(get_the_ID(), 'my_key', 'textarea');
    } else {
      echo get_post_meta(get_the_ID(), 'my_key', true);
    }
    ?>

    2) After editable_option has been included in the plugin, what of the dev guide do I need to have a look at (http://scribu.net/wordpress/front-end-editor/developer-guide.html)?

    If you don't want to create your own custom editable field type, you don't have to look at it at all.

    You can use editable_option() similarly to how you use editable_post_meta().

  3. iSimone
    Member
    Posted 3 years ago #

    Nice thanks scribu fort the if/else suggestion!

    I was trying to add a custom editable field type to my sidebar. A simple text field that I could change from the front end & I didn't know where to get started (since copying over the whole snippet from the dev page resulted in a double definition and a white page).

    btw. I found one issue (bug?) so far where I wanted to edit/add a tag from the frontend:

    <?php the_tags('<ul class="post-tags">

    gets a list of the post tags. When I doubleclick to edit/add a tag it opens all the previous tags -->

    * tumblog
    * vimeo
    * video

    Adding frontend as a tag results in

    * front-end editor, tumblog, video, vimeo
    * video
    * vimeo

    Is that intended behaviour?

  4. iSimone
    Member
    Posted 3 years ago #

    Is that correct? I get an syntax error, unexpected ')', expecting ',' or ';' in /Users/...

    <?php if ( function_exists('editable_post_meta') ) { editable_post_meta($post_id, 'image', 'textarea');} else { echo get_post_meta($post_id), 'image', true);}?>

    Sorry again, I'm not yet very experienced with tweaking my own stuff!

  5. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    It's very hard to debug and modify code if you stuff it all in one line like that.

    Here is the corrected version:

    <?php
    if ( function_exists('editable_post_meta') ) {
    	editable_post_meta($post_id, 'image', 'textarea');
    } else {
    	echo get_post_meta($post_id, 'image', true);
    }
    ?>
  6. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    btw. I found one issue (bug?) so far where I wanted to edit/add a tag from the frontend:

    <?php the_tags('<ul class="post-tags">

    Please paste the entire line.

  7. iSimone
    Member
    Posted 3 years ago #

    Sorry about that:

    <?php the_tags('<ul class="post-tags"><li>','</li><li>','</li></ul>'); ?>

  8. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    This is now fixed in the development version (1.9.2-alpha3).

  9. iSimone
    Member
    Posted 3 years ago #

    Nice!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic