Code Monkey home page Code Monkey logo

fuxt-backend's People

Contributors

dchiamp avatar drewbaker avatar lwaldner avatar montchr avatar rsm0128 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

fuxt-backend's Issues

Preview URL's for custom post types don't work

On the ILA site, they had a bunch of custom post types, amsterdam, paris and antwerp, We noticed that the "Preview" link from the editor wouldn't go to the correct auto-saved URL.

The solution was adding more hooks for these custom post types.
https://github.com/funkhaus/fuxt-backend/blob/master/functions/wp-functions.php#L207-L208

I would have thought that the generic rest_prepare_post would have worked for custom post types too, but it seems it doesn't: WP-API/WP-API#2419

So we could generate these action names dynamically, but querying for public post types with this: https://developer.wordpress.org/reference/functions/get_post_types/

Preview links not working

In the past, we've used this code to modify the Preview links in the WordPress dashboard to add some extra params to the URL, and to quickly toggle the draft post to published, and then back to draft.

https://github.com/funkhaus/fuxt-backend/blob/master/functions/wp-functions.php#L168-L209

This used to give the draft a real permalink, so we could query it using WP-GQL's nodeByUri query type.

But it seems recently WP has made it so that "drafts" never get a permalink. So toggling between published and draft doesn't work anymore.

The solution to this needs two parts. One, the Preview link in WordPress needs to be correct, but also the WP-GQL nodeByUri query needs to actually work too. So I think the best way to solve this is to figure out how to have WordPress allow permalinks on drafts, and hope that nodeByUri works with that. Rather than creating some hack to the Preview button in the dashboard to have a fake link.

This is a GQL query that I was using to test, with a post saved as a draft testing and the WP pretty permalink settings as /news/p/%postname%/.

query News {
  posts(first: 1, where: {status: DRAFT}) {
    nodes {
      id
      uri
      slug
    }
  }
  nodeByUri(uri: "/news/p/testing/") {
    id
    uri
  }
  post(id: "/news/p/testing/ ", idType: URI) {
    id
    uri
  }
}

ACF plugin critical error

Hello!

I'm trying to install fuxt with fuxt-backend.
I'm blocked at the plugin installation step by ACF. When using the auto-install, ACF pro can't be installed and throws this error:

Something went wrong with the plugin API.

I guess it's because I don't have a pro licence.

However, when I install the standard ACF plugin (non pro), either manually or through the plugin page, everything breaks instantly:

There has been a critical error on this website. Please check your site admin email inbox for instructions.

Is there a specific step I'm missing?
Thanks!

Dashboard Search doesn't work

If you disable the fuxt-backend theme, then Search works. Otherwise it redirects to the Dashboard landing page.
Screen Shot 2022-04-12 at 3 52 33 PM

I think this is related to the Nested Pages plugin in some way, as if you disable that plugin the search works too.

SameSite Cookie Manager

Getting an issue with SameSite Cookie Manager where it prevents me from logging into WordPress.

I believe this is likely an issue with the Plugin and not Fuxt. Although, I wanted to ask if anyone has experience anything similar?

What exactly is the plugin used for, is it a requirement?

Gutenberg editor: creating new lines of list blocks not working

First of all, thank you for this theme! Exactly what I needed.
I noticed a small bug, which only appears when I have this theme installed.
In the Gutenberg editor, when adding a text-list block and trying to hit the enter key to add a new line, simply nothing happens. I also cannot create a new line manually with the mouse. The only way to fix this is to temporarly switch to another theme, add the lines I need in the Gutenberg editor, and then switch back to fuxt.

Integrate cookie plugin into theme for better GraphCDN support

This is a plugin we currently use: https://github.com/MikhailRoot/samesite-cookie-manager/archive/refs/heads/master.zip

When using SSR sites with GraphCDN, we need to set the domain for cookies to .example.com, which isn't possible with Flywheel as they hard code the define() for COOKIE_DOMAIN to be the "WordPress Address (URL)".

So, I'd like to bring that code into the /functions directory, and upgrade it to use a settings field for the cookie domain. We have to be careful that we don't make it easy to allow the cookies to be set on a domain like "flywheelsites.com".

Scheduling a post doesn't work

The way that schedule works is someone has to load wordpress and it checks the the schedule... but with Headless WordPress, no one ever hits wordpress unless you login to the dashboard...

Perhaps sites with wp-controls would work, as that does a single request to wp-gql endpont, but I am not sure...

This was discovered on Wolf.

Build a custom proxy API endpoint

Build a custom REST API endpoint that can be used to proxy anything. Be sure to whitelist domains and origin from the frontend URL (or localhost).

Maybe we use it as an endpoint that hits the IP stack API and keeps our API key hidden for SSG sites.

Better domain origin protection?

This currently would allow other frontends to edit content on the site. That is bad.

I think the real fix is to change the origin header check to allow origins that are: wordpress install location, frontend location and local host.

NextPage returns random page

NextPage gql query is consistently returning incorrect pages.
This is unrelated to the recent looping update which works well, as its happening on older sites that weren't updates (like soda).

Here's a query example:
pages-query

you can see from the page structure that's incorrect
pages-next

NextPost is working as expected:
posts-query
posts-next

Abibility to use nextpage and prevPage to loop

Would be helpful if we could use a loop = true arg on the nextPage {} and previousPage{} page GQL nodes. It would then always give you the first/last when viewing the first or last item in a list.

This is the function that I updated to do it in gql-functions.php, but we need to get the GQL query working.

/*
 * Util function for adjacent page id
 *
 * Params: $page -> page object from wordpress
 * Params: $direction -> Integer -1 or 1 indicating next or previous post
 * returns adjacent page id
 */
function get_adjacent_page_id($page, $direction)
{
    $args = [
        "post_type" => $page->post_type,
        "order" => "ASC",
        "orderby" => "menu_order",
        "post_parent" => $page->post_parent,
        "fields" => "ids",
        "posts_per_page" => -1,
    ];

    $pages = get_posts($args);
    $current_key = array_search($page->ID, $pages);
    $output = 0;

    if (isset($pages[$current_key + $direction])) {
        // Next page exists
        $output = $pages[$current_key + $direction];
    }
    
    if(!$output && $direction > 0) {
	    $output = $pages[0];
    }
    if(!$output && $direction < 0) {
	    $output = $pages[ array_key_last($pages) ];
    }    
    
    return $output;
}

Feature request - Option to enable SVG uploads

Currently we have a hard time allowing clients to upload SVGs (mostly used for logo walls of awards or their clients). There is some code that we have to uncomment in wp-functions.php to allow it. It's commented off by default because of the danger that allowing SVGs pose to CMS and for people that might not be aware that we've allowed them...

So, I think we should build a option into the theme that can be toggled on and off (off by default). It's should be on the "writing" options page I think.

We should also test out uploading all the different SVG types and see what works and doesn't. Because I'm not even sure the code we have in the theme currently is the correct way to do it.

Allow next/prev post resolver arguments

So currently we have a custom resolver to get the next post, or page in a GQL query:
https://github.com/funkhaus/fuxt-backend/blob/master/functions/gql-functions.php#L141
https://github.com/funkhaus/fuxt-backend/blob/master/functions/gql-functions.php#L198

But when it comes to "next post" often we'd want to be able to set the params that the underlying WordPress functions allows for to get "next post in same category" : https://developer.wordpress.org/reference/functions/get_next_post/

$in_same_term = false
$excluded_terms = ''
$taxonomy = 'category'

Probably makes sense to "WP-GQL" style the naming convention here, and call it "termIn" rather than the "excluded_terms".

So I'd like to have some "resolver-arguments" for those settings:
https://www.wpgraphql.com/docs/graphql-resolvers/#resolver-arguments

So we could do this type of query on a post:

      nextPost(inSameTerm: true, termNotIn: '1,2,3', taxonomy: 'tag') {
        node {
          id
          title
        }
      }

Would be really helpful if we could allow those terms to be slugs also, so a termSlugNotIn as another argument that could be something like termSlugNotIn: 'featured, uncategorized'.

Now this it would also be really good if we could translate those same arguments for nextPage queries. So I could get next page that had the same tags. This isn't something there is a native WordPress function for, but you can see that it wouldn't be too hard to allow for same arguments for nextPage.
https://github.com/funkhaus/fuxt-backend/blob/master/functions/gql-functions.php#L182
https://github.com/funkhaus/fuxt-backend/blob/master/functions/gql-functions.php#L275

Has children ACF location rule

Would be great if you could use " has child" as a ACF location rule. Would be useful for page structures like this:

- Cars
- - BMW
- - - i3 <-- This one should have the ACF field group

Next/Prev Post not working as expected

Issue

It appears that the nextPost and previousPost queries are returning null unexpectedly.
Here is the list of posts on Optic Sky:
Screen Shot 2023-04-25 at 4 06 56 PM
The next/prevPost gql query should return the adjacent posts in that list (see arrow).

On the post detail page you can see they are both returning null:
Screen Shot 2023-04-25 at 4 06 41 PM

Previously we had issues where the query returned random posts for previous or next, but this is a new error where random posts return null for prev or next or both posts.

Links

repo
wordpress

ACF location rule "Has child"

It would be really useful to have an ACF location rule that allowed us to add a field group to a page that has NO children (or the opposite, only pages that have children)

/wp-login redirect loop

If you go to /wp-login and login with the right details, it redirects you back to the /wp-login page. Then you have to go to /wp-admin to get to the dashboard. I suspect this is related to the new cookie things built into the site.

I've also noticed that when you logout, it asks you to confirm that you want to log out... never seen that before.

Custom Gutenberg Block - Gallery Scrolling

We need a custom gutenberg block that builds a gallery, but one that shows a single row of images and has scrollbars to move it.

It's important the interface for this looks like a native WordPress block.

Inputs

  1. Gallery of images (should work same as regular gallery block with ordering etc...).

Output

  1. Images: Array of MediaItems in WP-GQL-Gutenberg.

Design:

On the frontend, we will style it to look like this (You do not have to build frontend Vue component):
Screen Shot 2021-05-23 at 4 05 30 PM

So the idea is a long row of images, that are sized 70vw and height auto, and then a "overflow-x: auto" container. Our frontend component will then have a "click and drag" style scroll in place on desktop, or swipe to scroll on mobile. We will use this: https://components.funkhaus.us/?path=/story/ui-scrollers-drag--default

Notes:

I tried getting this working with ACF Blocks here: https://github.com/funkhaus/fuxt-backend/tree/master/blocks

But it didn't work in WP-GQL-Gutenberg and also the interface looks a little ad-hock. This native block request will replace this block.

Next and Previous posts will be wrong depending on location of Gutenberg blocks in the GQL query

#import "~/gql/fragments/GutenbergBlocks.gql"

query NewsDetail($uri: String!) {
    nodeByUri(uri: $uri) {
        id
        ... on Post {
            title
            
            ...GutenbergBlocks # This will mean the nextPost and prevPost will not work!
            
            previousPost {
                node {
                    id
                    uri
                    title
                }
            }
            nextPost {
                node {
                    id
                    uri
                    title
                }
            }
            
            ...GutenbergBlocks # This will mean the nextPost and prevPost work
            
        }
    }
}

Very possible this is an issue with https://github.com/funkhaus/wp-gql-gutenberg

CORS errors when using Gutenberg editor

When using Gutennberg editor, the console logs a lot of errors:

Screen Shot 2021-04-12 at 2 35 03 PM

I tracked it down to this function: https://github.com/funkhaus/fuxt-backend/blob/master/functions/wp-functions.php#L280-L284

So now the question is, how to fix it? It seems weird that Gutenberg is doing API requests to the home URL, not the actual WordPress install URLs.

The whole point of that code was to get preview URL's linking out to the frontend correctly. So perhaps it's OK to just do a check for "is REST request" and if so, return the correct default home URL?

Custom Gutenberg Block - Cover with Logos

We want a gutenberg block that is an 70vh background image, with SVG logos overlaid in front of it.

It's important this block feel like a native WordPress block.

Inputs

  1. Background Image (one image)
  2. Logos (gallery of images)

Outputs

  1. Background Image (as a single MediaItem in WP-GQL)
  2. Logos (array of MediaItems in WP-GQL)

Design

We are going to use it like this on the frontend:
Screen Shot 2021-05-23 at 4 12 52 PM
Screen Shot 2021-05-23 at 4 13 31 PM

The each logo will be displayed in a 200px tall, auto width box always. Vertically and horizontally centered, and allowed to wrap onto new lines if enough logos uploaded.

Mostly the logos will be SVGs, but could also be PNGs or JPGs.

ACF location rule "is tree" doesn't work when combined with other rules

The "is tree" rule works on it's own, but when combined with "Page parent NOT equal too" it doesn't work.

This is the custom "is tree" rule.
https://github.com/funkhaus/fuxt-backend/blob/master/functions/acf-functions.php#L48-L55

A common use case for this is when we only want a field group to show up on deeper child pages, like:

  • Directors
    • Commercials
    • Music Videos
    • Films
      • Person Name

Having a field group only show up on "Person name".

Alternatively it would also be good to have a "No children" location ACF filter.

Blocked emails due to using frontend domain

Password reset emails (and any email from wordpress) get blocked, partly because WordPress is sending them with the "from" address being the frontend domain, which isn't actually the server sending them, it should be the backend domain.

So we should filter the default from address to be the backend domain.

SendGrid 2023-11-22 at 11 32 30 am

Enable ACF custom taxonimes and post types made in the UI to show in GraphQL

Currently the ACF plugin allows you to create a custom taxonimes and post types through the UI.

But it doesn't yet allow you to enable those in WP-GQL. I know it's planned to allow this, but in the meantime I'd like to auto enable all the ones that are made by ACF that also have show in rest API enabled (see screenshot).

For example, here is the code that allows you to set a pre-made taxonomy to show in GQL:

add_filter( 'register_taxonomy_args', function( $args, $taxonomy ) {

  if ( 'doc_tag' === $taxonomy ) {
    $args['show_in_graphql'] = true;
    $args['graphql_single_name'] = 'documentTag';
    $args['graphql_plural_name'] = 'documentTags';
  }

  return $args;

}, 10, 2 );

So it would just be a matter of making that work for custom post types too, and to do some test for show_in_rest to be true also.

Screenshot 2023-10-03 at 6 09 10 PM

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.