Forum Replies Created

Viewing 10 replies - 1 through 10 (of 10 total)
  • This worked for me… saved me from a heart attack, thanks guys!

    Thread Starter Roxanne

    (@onlinewoman)

    That was easy enough! Thanks so much 🙂

    Thread Starter Roxanne

    (@onlinewoman)

    That was it ipstenu! I hadn’t changed the wp-config. Bizzare though how it worked for the posts but just not for the pages!

    THANKS so much for your help!!

    Thread Starter Roxanne

    (@onlinewoman)

    Oh and I should add that all the posts resolve correctly when I change the database information from the IP address to the new domain. It is just the pages that seem to give the database error for some reason.

    Thread Starter Roxanne

    (@onlinewoman)

    Thanks for your help Andrea. First, I’m not sure what you mean by telling the webserver to answer to the domain. I have 3 other networks set up like this and all I’ve ever done was change the A-record, then make sure that the server recognizes one domain as the default so the mapping works for subsequent blog site? Perhaps I missed an important step in setup or something?

    Okay so I thought it was the same but that the MU elements were newly “built into” the old version (oy, too confusing for me to keep track! LOL).

    Here’s the domain: sdbaskets DOT com

    Thread Starter Roxanne

    (@onlinewoman)

    I wondered if it was a plugin issue but wasn’t sure. I’ll leave a post in their forum and see what they say. THANKS for the resources as I’ll look at them too and maybe find something that’ll cover this issue.

    Thread Starter Roxanne

    (@onlinewoman)

    So I know I’m really close, but somehow it’s not quite working yet. Here’s what I have, based on info from the link you provided.

    In my functions file:

    /**
    * Define custom field for ECWID HTML content
    */
    if ( !class_exists('myCustomFields') ) {
    
        class myCustomFields {
            /**
            * @var  string  $prefix  The prefix for storing custom fields in the postmeta table
            */
            var $prefix = '_mcf_';
            /**
            * @var  array  $customFields  Defines the custom fields available
            */
            var $customFields =    array(
                array(
                    "name"            => "ecwid-content",
                    "title"            => "ECWID HTML content",
                    "description"    => "",
                    "type"            => "textarea",
                    "scope"            =>    array( "post" ),
                    "capability"    => "edit_posts"
                )
            );
            /**
            * PHP 4 Compatible Constructor
            */
            function myCustomFields() { $this->__construct(); }
            /**
            * PHP 5 Constructor
            */
            function __construct() {
                add_action( 'admin_menu', array( &$this, 'createCustomFields' ) );
                add_action( 'save_post', array( &$this, 'saveCustomFields' ), 1, 2 );
                // Comment this line out if you want to keep default custom fields meta box
                add_action( 'do_meta_boxes', array( &$this, 'removeDefaultCustomFields' ), 10, 3 );
            }
            /**
            * Remove the default Custom Fields meta box
            */
            function removeDefaultCustomFields( $type, $context, $post ) {
                foreach ( array( 'normal', 'advanced', 'side' ) as $context ) {
                    remove_meta_box( 'postcustom', 'post', $context );
                    remove_meta_box( 'postcustom', 'page', $context );
                    //Use the line below instead of the line above for WP versions older than 2.9.1
                    //remove_meta_box( 'pagecustomdiv', 'page', $context );
                }
            }
            /**
            * Create the new Custom Fields meta box
            */
            function createCustomFields() {
                if ( function_exists( 'add_meta_box' ) ) {
                    add_meta_box( 'my-custom-fields', 'Custom Fields', array( &$this, 'displayCustomFields' ), 'page', 'normal', 'high' );
                    add_meta_box( 'my-custom-fields', 'Custom Fields', array( &$this, 'displayCustomFields' ), 'post', 'normal', 'high' );
                }
            }
            /**
            * Display the new Custom Fields meta box
            */
            function displayCustomFields() {
                global $post;
                ?>
                <div class="form-wrap">
                    <?php
                    wp_nonce_field( 'my-custom-fields', 'my-custom-fields_wpnonce', false, true );
                    foreach ( $this->customFields as $customField ) {
                        // Check scope
                        $scope = $customField[ 'scope' ];
                        $output = false;
                        foreach ( $scope as $scopeItem ) {
                            switch ( $scopeItem ) {
                                case "post": {
                                    // Output on any post screen
                                    if ( basename( $_SERVER['SCRIPT_FILENAME'] )=="post-new.php" || $post->post_type=="post" )
                                        $output = true;
                                    break;
                                }
                                case "page": {
                                    // Output on any page screen
                                    if ( basename( $_SERVER['SCRIPT_FILENAME'] )=="page-new.php" || $post->post_type=="page" )
                                        $output = true;
                                    break;
                                }
                            }
                            if ( $output ) break;
                        }
                        // Check capability
                        if ( !current_user_can( $customField['capability'], $post->ID ) )
                            $output = false;
                        // Output if allowed
                        if ( $output ) { ?>
                            <div class="form-field form-required">
                                <?php
                                switch ( $customField[ 'type' ] ) {
                                    case "checkbox": {
                                        // Checkbox
                                        echo '<label for="' . $this->prefix . $customField[ 'name' ] .'" style="display:inline;"><b>' . $customField[ 'title' ] . '</b></label>&nbsp;&nbsp;';
                                        echo '<input type="checkbox" name="' . $this->prefix . $customField['name'] . '" id="' . $this->prefix . $customField['name'] . '" value="yes"';
                                        if ( get_post_meta( $post->ID, $this->prefix . $customField['name'], true ) == "yes" )
                                            echo ' checked="checked"';
                                        echo '" style="width: auto;" />';
                                        break;
                                    }
                                    case "textarea":
                                    case "wysiwyg": {
                                        // Text area
                                        echo '<label for="' . $this->prefix . $customField[ 'name' ] .'"><b>' . $customField[ 'title' ] . '</b></label>';
                                        echo '<textarea name="' . $this->prefix . $customField[ 'name' ] . '" id="' . $this->prefix . $customField[ 'name' ] . '" columns="30" rows="3">' . htmlspecialchars( get_post_meta( $post->ID, $this->prefix . $customField[ 'name' ], true ) ) . '</textarea>';
                                        // WYSIWYG
                                        if ( $customField[ 'type' ] == "wysiwyg" ) { ?>
                                            <script type="text/javascript">
                                                jQuery( document ).ready( function() {
                                                    jQuery( "<?php echo $this->prefix . $customField[ 'name' ]; ?>" ).addClass( "mceEditor" );
                                                    if ( typeof( tinyMCE ) == "object" && typeof( tinyMCE.execCommand ) == "function" ) {
                                                        tinyMCE.execCommand( "mceAddControl", false, "<?php echo $this->prefix . $customField[ 'name' ]; ?>" );
                                                    }
                                                });
                                            </script>
                                        <?php }
                                        break;
                                    }
                                    default: {
                                        // Plain text field
                                        echo '<label for="' . $this->prefix . $customField[ 'name' ] .'"><b>' . $customField[ 'title' ] . '</b></label>';
                                        echo '<input type="text" name="' . $this->prefix . $customField[ 'name' ] . '" id="' . $this->prefix . $customField[ 'name' ] . '" value="' . htmlspecialchars( get_post_meta( $post->ID, $this->prefix . $customField[ 'name' ], true ) ) . '" />';
                                        break;
                                    }
                                }
                                ?>
                                <?php if ( $customField[ 'description' ] ) echo '<p>' . $customField[ 'description' ] . '</p>'; ?>
                            </div>
                        <?php
                        }
                    } ?>
                </div>
                <?php
            }
            /**
            * Save the new Custom Fields values
            */
            function saveCustomFields( $post_id, $post ) {
                if ( !wp_verify_nonce( $_POST[ 'my-custom-fields_wpnonce' ], 'my-custom-fields' ) )
                    return;
                if ( !current_user_can( 'edit_post', $post_id ) )
                    return;
                if ( $post->post_type != 'page' && $post->post_type != 'post' )
                    return;
                foreach ( $this->customFields as $customField ) {
                    if ( current_user_can( $customField['capability'], $post_id ) ) {
                        if ( isset( $_POST[ $this->prefix . $customField['name'] ] ) && trim( $_POST[ $this->prefix . $customField['name'] ] ) ) {
                            $value = $_POST[ $this->prefix . $customField['name'] ];
                            // Auto-paragraphs for any WYSIWYG
                            if ( $customField['type'] == "wysiwyg" ) $value = wpautop( $value );
                            update_post_meta( $post_id, $this->prefix . $customField[ 'name' ], $value );
                        } else {
                            delete_post_meta( $post_id, $this->prefix . $customField[ 'name' ] );
                        }
                    }
                }
            }
    
        } // End Class
    
    } // End if class exists statement
    
    // Instantiate the class
    if ( class_exists('myCustomFields') ) {
        $myCustomFields_var = new myCustomFields();
    }

    And, in my template:

    <?php if ($ecwid_content <> '') { ?>
                <?php echo($ecwid_content); ?>
                <?php }; ?>

    Have I messed it up too badly?

    Thread Starter Roxanne

    (@onlinewoman)

    That’s awesome! Okay, makes sense so I’ll give it a shot and see how it goes. Thanks again!

    Thread Starter Roxanne

    (@onlinewoman)

    Sorry another question… where should the php file be located? It doesn’t appear that any of this code references this file. How does the template call this file?

    Thread Starter Roxanne

    (@onlinewoman)

    David that was exactly what I needed, THANK YOU!

Viewing 10 replies - 1 through 10 (of 10 total)