Forum Replies Created

Viewing 15 replies - 1 through 15 (of 74 total)
  • Yes, I apologize, this is not yet deployed.

    Forum: Fixing WordPress
    In reply to: Editing old post
    Thread Starter beda69

    (@beda69)

    So well reading that guideline you probably wont delete my links 🙁

    It’s about this 2 posts:
    https://ww.wp.xz.cn/support/topic/custom-home-page-5
    https://ww.wp.xz.cn/support/topic/my-sites-access-after-signup

    All I would like to edit is the “my-homepage.com” (i wont be so stupid and post them again here)

    I would like to edit all links to my website to a “random” dummy URL

    Is it possible?

    It would be very great. Thank you

    Thread Starter beda69

    (@beda69)

    we need more info.
    can you elaborate?

    Is it a official theme, then no changes on your end should ever be made in the Themes files

    Is it your own built theme?

    Is it a free theme? if so, link to it?

    thanks

    Thread Starter beda69

    (@beda69)

    also, once you answer, might you elaborate:

    1. How do you store your data? Your courses, as example, seem to be Post Types but at same time, they seem not to be.

    I ask because I need to interact with the data of this plugin, but I can only if those are stored as classic post types.

    2. How do you store the relation Course-Module-Scholar-Teacher etc? custom fields? post meta?

    Thanks

    Thread Starter beda69

    (@beda69)

    thanks for follow up.

    I solved the issues and non-features-

    1. Email notification solved with custom function that triggers wp_mail if @username is found in post/comment (and a bunch of other stuff)

    2. No drop Down in Post body, if post is not default page or post
    I should have specified that.
    Solved by adding a pointer to the correct JS.

    BTW. re-downloading and overwriting the P” default jquery. autocomplete.js solved another issue:
    users where not “toogeable” in popping up list of users when @username is typed.

    If P2’s files are overwritten this works fine.

    All issues solved.

    (Apart from a bunch of errors that P2 throws on activation with wp-debug=true)
    But that seems soled in P3.

    Thanks!

    Thread Starter beda69

    (@beda69)

    OK, here comes a partial “solution” to this

    I am working with bootstrap therefore some things might change from theme to theme…

    Include in your current themes functions.php at the very top this one:

    require_once( get_template_directory() . '/inc/utils.php' );
    
    p2_maybe_define( 'P2_INC_PATH', get_template_directory()     . '/inc' );
    p2_maybe_define( 'P2_INC_URL',  get_template_directory_uri() . '/inc' );
    p2_maybe_define( 'P2_JS_PATH',  get_template_directory()     . '/js'  );
    p2_maybe_define( 'P2_JS_URL',   get_template_directory_uri() . '/js'  );
    
    class P2 {
        /**
    	 * DB version.
    	 *
    	 * @var int
    	 */
        var $db_version = 3;
    
        /**
    	 * Options.
    	 *
    	 * @var array
    	 */
        var $options = array();
    
        /**
    	 * Option name in DB.
    	 *
    	 * @var string
    	 */
        var $option_name = 'p2_manager';
    
        /**
    	 * Components.
    	 *
    	 * @var array
    	 */
        var $components = array();
    
        /**
    	 * Includes and instantiates the various P2 components.
    	 */
        function P2() {
            // Fetch options
            $this->options = get_option( $this->option_name );
            if ( false === $this->options )
                $this->options = array();
    
            // Include the P2 components
            $includes = array( 'compat', 'terms-in-comments', 'js-locale',
                              'mentions', 'search', 'js', 'options-page', 'widgets/recent-tags', 'widgets/recent-comments',
                              'list-creator' );
    
            require_once( P2_INC_PATH . "/template-tags.php" );
    
            // Logged-out/unprivileged users use the add_feed() + ::ajax_read() API rather than the /admin-ajax.php API
            // current_user_can( 'read' ) should be equivalent to is_user_member_of_blog()
            if ( defined( 'DOING_AJAX' ) && DOING_AJAX && ( p2_user_can_post() || current_user_can( 'read' ) ) )
                $includes[] = 'ajax';
    
            foreach ( $includes as $name ) {
                require_once( P2_INC_PATH . "/$name.php" );
            }
    
            // Add the default P2 components
            $this->add( 'mentions',             'P2_Mentions'             );
            $this->add( 'search',               'P2_Search'               );
            $this->add( 'post-list-creator',    'P2_Post_List_Creator'    );
            $this->add( 'comment-list-creator', 'P2_Comment_List_Creator' );
    
            // Bind actions
            add_action( 'init',       array( &$this, 'init'             ) );
            add_action( 'admin_init', array( &$this, 'maybe_upgrade_db' ), 5 );
        }
    
        function init() {
    
        }
    
        function ajax_read() {
            if ( ! defined( 'DOING_AJAX' ) ) {
                define( 'DOING_AJAX', true );
            }
    
            require_once( P2_INC_PATH . '/ajax-read.php' );
    
            P2Ajax_Read::dispatch();
        }
    
        /**
    	 * Will upgrade the database if necessary.
    	 *
    	 * When upgrading, triggers actions:
    	 *    'p2_upgrade_db_version'
    	 *    'p2_upgrade_db_version_$number'
    	 *
    	 * Flushes rewrite rules automatically on upgrade.
    	 */
        function maybe_upgrade_db() {
            if ( ! isset( $this->options['db_version'] ) || $this->options['db_version'] < $this->db_version ) {
                $current_db_version = isset( $this->options['db_version'] ) ? $this->options['db_version'] : 0;
    
                do_action( 'p2_upgrade_db_version', $current_db_version );
                for ( ; $current_db_version <= $this->db_version; $current_db_version++ ) {
                    do_action( "p2_upgrade_db_version_$current_db_version" );
                }
    
                // Flush rewrite rules once, so callbacks don't have to.
                flush_rewrite_rules();
    
                $this->set_option( 'db_version', $this->db_version );
                $this->save_options();
            }
        }
    
        /**
    	 * COMPONENTS API
    	 */
        function add( $component, $class ) {
            $class = apply_filters( "p2_add_component_$component", $class );
            if ( class_exists( $class ) )
                $this->components[ $component ] = new $class();
        }
        function get( $component ) {
            return $this->components[ $component ];
        }
        function remove( $component ) {
            unset( $this->components[ $component ] );
        }
    
        /**
    	 * OPTIONS API
    	 */
        function get_option( $key ) {
            return isset( $this->options[ $key ] ) ? $this->options[ $key ] : null;
        }
        function set_option( $key, $value ) {
            return $this->options[ $key ] = $value;
        }
        function save_options() {
            update_option( $this->option_name, $this->options );
        }
    }
    
    $GLOBALS['p2'] = new P2;
    
    function p2_get( $component = '' ) {
        global $p2;
        return empty( $component ) ? $p2 : $p2->get( $component );
    }
    function p2_get_option( $key ) {
        return $GLOBALS['p2']->get_option( $key );
    }
    function p2_set_option( $key, $value ) {
        return $GLOBALS['p2']->set_option( $key, $value );
    }
    function p2_save_options() {
        return $GLOBALS['p2']->save_options();
    }

    then include the JS and INC folders in your Theme

    Remove from js/jquery.jeditable.js this one (otherwise your Bootstrap “Submit Comment” button breaks) :

    defaults: {
                    element : function(settings, original) {
                        var input = $('<input type="hidden"></input>');
                        $(this).append(input);
                        return(input);
                    },
                    content : function(string, settings, original) {
                        $(':input:first', this).val(string);
                    },
                    reset : function(settings, original) {
                      original.reset(this);
                    },
                    buttons : function(settings, original) {
                        var form = this;
                        if (settings.submit) {
                            /* if given html string use that */
                            if (settings.submit.match(/>$/)) {
                                var submit = $(settings.submit).click(function() {
                                    if (submit.attr("type") != "submit") {
                                        form.submit();
                                    }
                                });
                            /* otherwise use button with given string as text */
                            } else {
                                var submit = $('<button type="submit" />');
                                submit.html(settings.submit);
                            }
                            $(this).append(submit);
                        }
                        if (settings.cancel) {
                            /* if given html string use that */
                            if (settings.cancel.match(/>$/)) {
                                var cancel = $(settings.cancel);
                            /* otherwise use button with given string as text */
                            } else {
                                var cancel = $('<button type="cancel" />');
                                cancel.html(settings.cancel);
                            }
                            $(this).append(cancel);
    
                            $(cancel).click(function(event) {
                                //original.reset();
                                if ($.isFunction($.editable.types[settings.type].reset)) {
                                    var reset = $.editable.types[settings.type].reset;
                                } else {
                                    var reset = $.editable.types['defaults'].reset;
                                }
                                reset.apply(form, [settings, original]);
                                return false;
                            });
                        }
                    }
                },

    This works with a few glitches, which i’ll post next… just give me some time 🙂

    Thread Starter beda69

    (@beda69)

    OK; i thank you

    very nice your help.

    solved, will eventually present this in a tutorial once done

    Thread Starter beda69

    (@beda69)

    thanks

    I tried a “find by exclude” process, and as far aI see all JS folder files are quiet necessary + ca. 1/2 of the inc folder too.

    I was able to reduce your theme down to the essential functions mention by you above, but still it requires many js files to “work”

    will get there.

    A final one:

    I see it is not supported to “tag” users in POST BODY, even though you include “the_content” in the filter hook.

    Any reasons why only comments have the fancy “pop up” when start typing?

    AND

    Whats about email notifications on tagging?

    I am on MAMP therefore bit difficult to check if it gives me notifications on tag event.

    Perhaps you can enlighten me?

    then I will happily close this one and go ahead 😀

    Thread Starter beda69

    (@beda69)

    thanks

    I saw that, but this is not what I need i guess.

    I see the “mentions” file is included in this, would it mean, I need to integrate ALL those files:
    ( ‘compat’, ‘terms-in-comments’, ‘js-locale’,
    ‘mentions’, ‘search’, ‘js’, ‘options-page’, ‘widgets/recent-tags’, ‘widgets/recent-comments’,
    ‘list-creator’ )
    or could I work just with the Mentions file?

    I will try… 😀

    thanks for this (and more) info 😀

    Thread Starter beda69

    (@beda69)

    Why is it working in this very forum?

    Does ww.wp.xz.cn use a special plugin or custom code to render the code properly?

    It makes poor sense that the very support forum accepts my code above, but the default (user end) WP “Text” Editor cuts of code, makes <img src> tags to links and $code to /code>

    This is odd.

    Any suggestion from the devs of this very support forum is very welcome

    Thread Starter beda69

    (@beda69)

    also pre formatting with <pre and </pre tags, does not really make it nicer

    Thread Starter beda69

    (@beda69)

    The only way I get this to work (I tested online to be sure)

    <a class="navbar-brand" href="<?php echo esc_url( home_url( '/' ) ); ?>">
                                        <img alt="Brand" src="<?php bloginfo('template_directory'); ?>/images/icon.png" style="max-width: 30px;">
                                    </a>

    OR

    <a class="navbar-brand" href="<?php echo esc_url( home_url( '/' ) ); ?>">
                                        <img alt="Brand" src="http://mysite.com/wp-content/themes/mytheme/images/icon.png" style="max-width: 30px;">
                                    </a>

    OR

    <a class="navbar-brand" href="<?php echo esc_url( home_url( '/' ) ); ?>">
                                        <img alt="Brand" src="./wp-content/themes/mytheme/images/icon.png" style="max-width: 30px;">
                                    </a>

    According to all DOC i read, this should also work, but it does not

    Not sure if this works only in CSS field though

    Thread Starter beda69

    (@beda69)

    does not seem to be so.

    I checked 80% of theme 2014’s files and the only I found was:
    <img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>">

    I use this:

    <img alt="Brand" src="./images/icon.png" style="max-width: 30px;">

    and if I use Brackets to code, and hover over that piece of code, correctly the image displays on hover

    However, if I load the page in Firefox, image is broken and the console tells me “Could not load image” and the ONLY that works in console is if I change the

    src="./images/icon.png"

    part to:

    <img alt="Brand" src="http://localhost:8888/mysite/wp-content/themes/mytheme/images/icon.png" style="max-width: 30px;">

    and this is for sure not the way it should be achieved.

    To you recommend to create a variable and then get it with a call to?

    like

    $imagepath = get_template_directory() . '/images/';

    and then echo it?

    I am not sure this is the good approach!

    thank you

    Thread Starter beda69

    (@beda69)

    hello

    thanks for te reply

    i see it can’t be done with simple php

    will look into that AJAX and post my findings here….

    tnx

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