Forum Replies Created

Viewing 11 replies - 1 through 11 (of 11 total)
  • OK… fixed it… My plugin had uploaded with a folder name that wasn’t ‘wordfence’. While much of the interface was working after activating the plugin, critical javascripts, and perhaps other items, did not load.

    Renaming the word fence plugin folder to ‘wordfence’ and restarting the plugin fixed all problems.

    I’m getting a javascript error “WFAD is not defined” in admin.php:1:0

    There seems to be a more general problem… If I try to manually start a scan, nothing happens by way of a scan starting and I get the following error:

    ReferenceError: wordfenceAdmin is not defined

    Latest versions of WF and WP

    Same here. Can edit when I create the service, but as soon as it gets saved fields are uneditable.

    I do get a console error (javascript) from a totally different plugin… “reference Error: require is not defined”

    TIA

    Line #141 needs editing to become:

    <?php FaqForm( 1 ,stripslashes( trim( $result['question'] ) ), stripslashes( trim( $result['answer'] ) ), true, $category_list, $active_categories ); ?>

    That should fix the runaway backslashes, but you will have to manually remove any backslashes that have been recorded to the database by previous edits. Once that’s done any subsequent edit will not now be adding backslashes in the editor.

    Change line 29 in wp-responsive-faqs/src/admin_menu.php as below fixes the issue.

    <?php require(dirname(__FILE__) . '/partials/_form_elements.php' ) ?>

    The same change also needs to be made to line 211

    Thread Starter lostSqualo

    (@lostsqualo)

    OK,

    Looks as if line #141 needs to be changed to strip slashes when editing a FAQ…

    Line #141 becomes:

    <?php FaqForm( 1 ,stripslashes( trim( $result['question'] ) ), stripslashes( trim( $result['answer'] ) ), true, $category_list, $active_categories ); ?>

    That should fix the runaway backslashes.

    Thread Starter lostSqualo

    (@lostsqualo)

    Hi nanonanouk,

    Thanks for that… works a dream, but the same change also needs to be applied to line 211 of the same file. Failure to make that change means that adding categories, and filtering the list of FAQs by category in admin doesn’t work.

    There is also a problem with escaping single and double quotes in the answer texts, such that you end up with runaway \\\\\’s if you forget to manually remove the damn things. Not located that problem yet.

    Cheers

    Thread Starter lostSqualo

    (@lostsqualo)

    Hi,

    Many thanks for what sounds like a great update… Only problem is that the admin page fails to load in WP 3.8.5, whereas the older plugin version (1.1) the admin loads just fine.

    The two installations I’m currently running cannot yet be updated to 4.0.*, so I’m stuck with an old version of the plugin and unable to sort.

    FYI, if I use the old version to add FAQs, and then install version 1.3, the WP-FAQ page still does not load, but the FAQs do load OK on the front-end page. So the problem appears to be with the admin page only.

    Thanks in advance

    Agreed this would be useful. Only way of doing something like this currently is to use inline tags like br to create ‘paragraph’ breaks…

    Adding lists or real paragraphs (any block-level markup) breaks the default formatting and then requires CSS changes to ensure retention of styling for consistent look/feel.

    Why not at least allow for the name to be edited, so the default category can be meaningful!

    Thread Starter lostSqualo

    (@lostsqualo)

    Hi,

    Editing back the code and breaking it down to more manageable pieces. First create the theme options page and menu item under ‘Appearance’:

    /* ------------------------------------------------------------------------ *
     * Custom Theme Options page
     * ------------------------------------------------------------------------ */   
    
    function bm_theme_menu() {
        add_theme_page(
            'BM Options',		// The title to be displayed in the browser window for this page.
            'BM Options',		// The text to be displayed for this menu item
            'administrator',				// Which type of users can see this menu item
            'bm_theme_display_options',		// The unique ID - that is, the slug - for this menu item
            'bm_theme_display'				// The name of the function to call when rendering the page for this menu
        );
    }
    add_action('admin_menu', 'bm_theme_menu'); 
    
    function bm_theme_display() {
    ?>
        <div class="wrap">
            <div id="icon-themes" class="icon32"></div>
            <h2>Blue Mountains Options</h2>
            <p class="description">There are currently no options. This is just for demo purposes.</p>
    
            <form method="post" action="options.php">
                <?php settings_fields( 'bm_theme_display_options' ); ?>
                <?php do_settings_sections( 'bm_theme_display_options' ); ?>
                <?php submit_button(); ?>
            </form>
        </div>
    	<?php
    }

    Next, sections and fields, registering the fields collectively with WordPress:

    /* ------------------------------------------------------------------------
    //	Settings sections and fields
    //------------------------------------------------------------------------ */   
    
    function bm_initialize_theme_options() {
    	if( false == get_option( 'bm_theme_display_options' ) ) {
    		add_option( 'bm_theme_display_options' );
    	}
    
        add_settings_section(
            'bm_global_info',
            'BM Global Info',
            'bm_general_options_callback',
            'bm_theme_display_options'
        );
    
    	add_settings_field(
    		'contact_phone',
    		'Contact Phone Number',
    		'bm_contact_phone_callback',
    		'bm_theme_display_options',
    		'bm_global_info',
    		array(
    			'Your Primary Contact Phone Number'
    		)
    	);
    	add_settings_field(
    		'copyright_from',
    		'Copyright starting from (year)',
    		'bm_copyright_from_callback',
    		'bm_theme_display_options',
    		'bm_global_info',
    		array(
    			'[yyyy] Year from which to start copyright notice in footer'
    		)
    	);
    /* ------------------------------------------------------------------------
    //	Register fields with WordPress
    //------------------------------------------------------------------------ */
    	register_setting(
    		'bm_theme_display_options',
    		'bm_theme_display_options',
        	'bm_sanitize_display_options'
    	);
    }
    
    add_action('admin_init', 'bm_initialize_theme_options');

    Lastly, the callbacks and sanitizer. I’m using the sanitizer to help debug what is happening… essentially it shows that the $input array comes through empty. If I use the same to check the $_POST array then that shows content, so the problem lies in getting the contents of $_POST into the $input array.

    /* ------------------------------------------------------------------------
    //	Section Callbacks
    //------------------------------------------------------------------------ */   
    
    function bm_general_options_callback() {
        echo '<p>Setup global information for use on the website</p>';
    } // end sandbox_general_options_callback  
    
    function bm_contact_phone_callback($args) {
    	$options = get_option('bm_theme_display_options');
        $html = '<input type="text" id="contact_phone" name="contact_phone" value="' . $options['contact_phone'] . '" />';
        $html .= '<label for="contact_phone"> '  . $args[0] . '</label>';  
    
        echo $html;  
    
    } // end sandbox_contact_phone_callback
    function bm_copyright_from_callback($args) {
    	$options = get_option('bm_theme_display_options');
        $html = '<input type="text" id="copyright_from" name="copyright_from" value="' . $options['copyright_from'] . '" />';
        $html .= '<label for="copyright_from"> '  . $args[0] . '</label>';  
    
        echo $html;  
    
    } // end sandbox_contact_phone_callback  
    
    function bm_sanitize_display_options( $input ) {
    /*
    //	This for debugging... shows $input to be empty
    */
    echo "INPUT:<br>\n";
    print_r($input);
    echo "DONE!<br>\n";
    
        $output = array();
        foreach( $input as $key => $val ) {
            if( isset ( $input[$key] ) ) {
                $output[$key] = esc_url_raw( strip_tags( stripslashes( $input[$key] ) ) );
            }
        }
        return apply_filters( 'sandbox_theme_sanitize_social_options', $output, $input );
    }

    Thanks for whatever assistance you can give

    Cheers

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