Forum Replies Created

Viewing 15 replies - 1 through 15 (of 20 total)
  • Thread Starter isaacbenh

    (@isaacbenh)

    Added menu_bar: true and I can see it now, but I still have to manually specify all the advanced plugins in the settings. I wonder why WordPress doesn’t have the default settings in wp.editor like it does when you use wp_editor()

    • This reply was modified 4 years, 6 months ago by isaacbenh.
    • This reply was modified 4 years, 6 months ago by isaacbenh.
    Thread Starter isaacbenh

    (@isaacbenh)

    Okay, it seems to upload two folders. Noticed this just know. Sorry for false alarm and thanks for making this plugin.

    Thread Starter isaacbenh

    (@isaacbenh)

    Okay, your way technically works, but that means I need to rely on the time they were entered instead of a real relationship like in a separate table. Both are as easy, I just don’t get the caching with the custom table.

    Thread Starter isaacbenh

    (@isaacbenh)

    Sorry, missed your response.
    My problem is that each round has multiple values which are connected to each other.
    If I make my own I store everything in one row. So I will have a “round_number”, “amount”, and “date” columns.
    I’m not sure how all these CPT plugins do that, but it seems confusing to have duplication of keys. And I also don’t understand how to connect between the keys.
    If round number 1 has amount of $100000 how can I be sure it won’t get another amount that belongs to another round?

    Thread Starter isaacbenh

    (@isaacbenh)

    Thanks, I created a DB table eventually. I read these docs. They don’t tell you anything about repeatable fields.
    From what I checked I had to create a child post type which is not advised according to the WordPress codex or to create a table.

    Thread Starter isaacbenh

    (@isaacbenh)

    Thanks, here is the end solution. Now it will do the insert in one query instead.

    $query = "INSERT INTO $table_name (post_id, amount_raised, round_number, raised_date) VALUES";
    $query_parts = array();
    for ( $i = 0; $i < $count; $i++ )
    {
        $query_parts[] = "('$post_id', '$amount_raised[$i]', '$round_number[$i]', '$raised_date[$i]')";
    }
    $query .= implode(',', $query_parts);
    $wpdb->query( $query );
    Thread Starter isaacbenh

    (@isaacbenh)

    Okay, I have a problem with my code I think.

    Thread Starter isaacbenh

    (@isaacbenh)

    Thanks, solved it by playing with capabilities eventually.
    I added this:

    function allow_author_uploads()
    {
        $user_role = 'author';
        $author = get_role($user_role);
        $author->add_cap('edit_others_pages');
        $author->add_cap('edit_published_pages');
    
    }
    add_action('init', 'allow_author_uploads');

    Thread Starter isaacbenh

    (@isaacbenh)

    Seems like that these were missing:

    $attach_data = wp_generate_attachment_metadata( $attach_id, $movefile['file'] );
        wp_update_attachment_metadata( $attach_id, $attach_data );

    Thread Starter isaacbenh

    (@isaacbenh)

    I think I solved it, but now I have a problem with the “next_posts_link”.
    I want it to be based on events page, but it’s based on the API URL which is bad:

    <a href="https://localhost:8888/water/wp-json/events/v1/events/page/2/?event_date=2016-08-25" ><button class="ath-btn ath-btn-info">LOAD MORE</button></a></div>

    This is the structure I need:

    href="//localhost:8888/water/events/page/2/"

    Any ideas how to solve this?

    Thread Starter isaacbenh

    (@isaacbenh)

    Sorry, I missed it.

    Notice: Undefined index: event in /Applications/MAMP/htdocs/water/wp-content/themes/water-bootstrap/post-types/tweet.php on line 63

    What I think happens is that my tweet posts type code runs after the event post type code and overrides it, because of course there wouldn’t be an event index in tweet.php, it is in event.php.
    I just run this at the beginning of the function and errors are gone.

    if( $post_type !== 'tweet' )
    	{
    		return;
    	}

    I run the same on the event post type code

    if( $post_type !== 'event' )
    	{
    		return;
    	}

    It goes inside the function that updates the admin messages.
    I’m just afraid I’m missing a bigger problem and it will blow up in production ??

    Thread Starter isaacbenh

    (@isaacbenh)

    Maybe from the beginning I need to make sure which post type it refers to. I have a duplicate of this for the other post type.

    Thread Starter isaacbenh

    (@isaacbenh)

    This is the full code:

    function tweet_updated_messages( $messages )
    {
        $post             = get_post();
        $post_type        = get_post_type( $post );
        $post_type_object = get_post_type_object( $post_type );
    
        $messages['tweet'] = array(
    		0  => '', // Unused. Messages start at index 1.
    		1  => __( 'Tweet updated.', 'your-plugin-textdomain' ),
    		2  => __( 'Custom field updated.', 'your-plugin-textdomain' ),
    		3  => __( 'Custom field deleted.', 'your-plugin-textdomain' ),
    		4  => __( 'Tweet updated.', 'your-plugin-textdomain' ),
    		/* translators: %s: date and time of the revision */
    		5  => isset( $_GET['revision'] ) ? sprintf( __( 'Tweet restored to revision from %s', 'your-plugin-textdomain' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
    		6  => __( 'Tweet published.', 'your-plugin-textdomain' ),
    		7  => __( 'Tweet saved.', 'your-plugin-textdomain' ),
    		8  => __( 'Tweet submitted.', 'your-plugin-textdomain' ),
    		9  => sprintf(
    			__( 'Tweet scheduled for: <strong>%1$s</strong>.', 'your-plugin-textdomain' ),
    			// translators: Publish box date format, see https://php.net/date
    			date_i18n( __( 'M j, Y @ G:i', 'your-plugin-textdomain' ), strtotime( $post->post_date ) )
    		),
    		10 => __( 'Tweet draft updated.', 'your-plugin-textdomain' )
    	);
    
    	if ( $post_type_object->publicly_queryable  )
        {
    		$permalink = get_permalink( $post->ID );
    
    		$view_link = sprintf( ' <a href="%s">%s</a>', esc_url( $permalink ), __( 'View tweet', 'your-plugin-textdomain' ) );
    		$messages[ $post_type ][1] .= $view_link;
    		$messages[ $post_type ][6] .= $view_link;
    		$messages[ $post_type ][9] .= $view_link;
    
    		$preview_permalink = add_query_arg( 'preview', 'true', $permalink );
    		$preview_link = sprintf( ' <a target="_blank" href="%s">%s</a>', esc_url( $preview_permalink ), __( 'Preview tweet', 'your-plugin-textdomain' ) );
    		$messages[ $post_type ][8]  .= $preview_link;
    		$messages[ $post_type ][10] .= $preview_link;
    	}
    
    	return $messages;
    }
    add_filter( 'post_updated_messages', 'tweet_updated_messages' );

    Thread Starter isaacbenh

    (@isaacbenh)

    Hey,
    I rolled my own infinite scroll functionality and I have the same problem. It might be caused by browser-sync or something. Clearly your plugin has no problems. Sorry for wasting your time.

    Thread Starter isaacbenh

    (@isaacbenh)

    For now this solved it. Have no idea why.

    function include_post_type( $query ) {
        if ( $query->is_front_page() && $query->is_main_query() ) {
            $query->set( 'post_type', array( 'post', 'tweet' ) );
    		return;
        }
    }
    add_action( 'pre_get_posts', 'include_post_type' );

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