Forum Replies Created

Viewing 11 replies - 16 through 26 (of 26 total)
  • Thread Starter drzraf

    (@drzraf)

    I still think there a lack of documentation on this topic.

    Thread Starter drzraf

    (@drzraf)

    class Server {
        public function initialize() {
            add_action('plugins_loaded', [__CLASS__, 'plugins_loaded']);
       }
      static function plugins_loaded() {
            add_filter( 'rest_allow_anonymous_comments', '__return_true' );
      }
    }
    $x = new \Foo\Server();
    $x->initialize();
    Thread Starter drzraf

    (@drzraf)

    great, that works!
    From a quick look at the diff’ it seems to mean that PPC custom permissions are simply “ignored” for REST, and I think it’s the good thing to do, for the moment.

    thank you!

    Thread Starter drzraf

    (@drzraf)

    $ GET http://localhost/wp-json/wp/v2/fooo/21536
    {object...} # OK with PPC enabled or not

    $ GET http://localhost/wp-json/wp/v2/fooo # PPC enabled
    []

    $ GET http://localhost/wp-json/wp/v2/fooo # PPC disabled
    [{normal full array of objects}]

    $ wp option get capsman_backup Permissions (is that the “backup” way?)

    ‘fooo’ =>
    array (
    ‘name’ => ‘Foos Editor’,
    ‘capabilities’ =>
    array (
    ‘edit_post’ => true,
    ‘read_post’ => true,
    ‘delete_post’ => true,
    ‘read’ => true,
    ‘edit_fooos’ => true,
    ‘publish_fooos’ => true,
    ‘edit_published_fooos’ => true,
    ‘edit_private_fooos’ => true,
    ‘delete_fooos’ => true,
    ‘delete_published_fooos’ => true,
    ‘delete_private_fooos’ => true,
    ‘level_0’ => true,
    ‘read_private_fooos’ => true,
    ‘edit_others_fooos’ => true,
    ‘delete_others_fooos’ => true,
    ‘upload_files’ => true,
    ),
    ),

    $ wp eval 'var_export(get_post_type_object("foo"));'

    WP_Post_Type::__set_state(array(
    ‘name’ => ‘foo’,
    ‘label’ => ‘Foos’,
    ‘labels’ =>
    stdClass::__set_state(array(
    ‘name’ => ‘Foos’,
    ‘singular_name’ => ‘Foo’,
    ‘add_new’ => ‘Ajouter’,
    ‘add_new_item’ => ‘Ajouter un nouveau foo’,
    ‘edit_item’ => ‘Modifier le foo’,
    ‘new_item’ => ‘Nouveau foo’,
    ‘view_item’ => ‘Voir le foo’,
    ‘view_items’ => ‘Voir les articles’,
    ‘search_items’ => ‘Chercher un foo’,
    ‘not_found’ => ‘Aucun foo trouvé’,
    ‘not_found_in_trash’ => ‘Aucun foo trouvé dans la corbeille’,
    ‘parent_item_colon’ => ‘Foo parent:’,
    ‘all_items’ => ‘Foos’,
    ‘archives’ => ‘Foos’,
    ‘attributes’ => ‘Attributs d’articles’,
    ‘insert_into_item’ => ‘Insérer dans l’article’,
    ‘uploaded_to_this_item’ => ‘Mis en ligne sur cet article’,
    ‘featured_image’ => ‘Image mise en avant’,
    ‘set_featured_image’ => ‘Définir l’image mise en avant’,
    ‘remove_featured_image’ => ‘Supprimer l’image mise en avant’,
    ‘use_featured_image’ => ‘Utiliser comme image mise en avant’,
    ‘filter_items_list’ => ‘Filtrer la liste des articles’,
    ‘items_list_navigation’ => ‘Navigation de la liste des articles’,
    ‘items_list’ => ‘Liste des articles’,
    ‘menu_name’ => ‘Foos’,
    ‘name_admin_bar’ => ‘Foo’,
    )),
    ‘description’ => ”,
    ‘public’ => true,
    ‘hierarchical’ => false,
    ‘exclude_from_search’ => false,
    ‘publicly_queryable’ => true,
    ‘show_ui’ => true,
    ‘show_in_menu’ => true,
    ‘show_in_nav_menus’ => true,
    ‘show_in_admin_bar’ => true,
    ‘menu_position’ => 30,
    ‘menu_icon’ => ”,
    ‘capability_type’ => ‘foo’,
    ‘map_meta_cap’ => true,
    ‘register_meta_box_cb’ => NULL,
    ‘taxonomies’ =>
    array (
    ),
    ‘has_archive’ => false,
    ‘query_var’ => ‘foo’,
    ‘can_export’ => true,
    ‘delete_with_user’ => NULL,
    ‘_builtin’ => false,
    ‘_edit_link’ => ‘post.php?post=%d’,
    ‘cap’ =>
    stdClass::__set_state(array(
    ‘edit_post’ => ‘edit_post’,
    ‘read_post’ => ‘read_post’,
    ‘delete_post’ => ‘delete_post’,
    ‘edit_posts’ => ‘edit_foos’,
    ‘edit_others_posts’ => ‘edit_others_foos’,
    ‘publish_posts’ => ‘publish_foos’,
    ‘read_private_posts’ => ‘read_private_foos’,
    ‘read’ => ‘read’,
    ‘delete_posts’ => ‘delete_foos’,
    ‘delete_private_posts’ => ‘delete_private_foos’,
    ‘delete_published_posts’ => ‘delete_published_foos’,
    ‘delete_others_posts’ => ‘delete_others_foos’,
    ‘edit_private_posts’ => ‘edit_private_foos’,
    ‘edit_published_posts’ => ‘edit_published_foos’,
    ‘create_posts’ => ‘edit_foos’,
    )),
    ‘rewrite’ => false,
    ‘show_in_rest’ => true,
    ‘rest_base’ => ‘foo’,
    ‘rest_controller_class’ => ‘WP_REST_Posts_Controller’,
    ‘plural_name’ => ‘foos’,
    ))

    $ wp plugin list --status=active

    advanced-custom-fields-pro active none 5.6.1
    capability-manager-enhanced active none 1.5.7
    page-list active none 5.1
    post-duplicator active none 2.20
    press-permit-core active none 2.3.21
    simple-custom-types active none 3.4

    • This reply was modified 8 years, 12 months ago by drzraf. Reason: formatting
    Thread Starter drzraf

    (@drzraf)

    Just tried ppc 2.3.21 today. The issue still exist in some form:
    In query-interceptor_pp.php l.519: else { $where_arr[$post_type] = '1=2';
    Specifically, this block custom post type listing:
    Ex: /wp-json/wp/v2/restaurant

    plugin seems triggered when you edit/create a new post
    But in my case it fails here

    admin/class-acf-form-builder-admin.php
    177 $form_settings = unserialize($get_post_meta['form_settings'][0]);

    because post meta does not have such a form_settings key.
    (seems buggy)

    Thread Starter drzraf

    (@drzraf)

    Part of a solution but not enough.

    I found the second restriction to be the one inside exceptions_pp.php
    at line 67 else { $where = '1=2'; }

    And fixing the second with an elseif rather than 1=1, I found there was still an issue, with queries like ( wp_posts.post_type = 'xxx' AND ( Array ) )

    The reason being that no $wherebeing defined inside exceptions_pp.php, if ( $append_post_type_clause ) { creates a buggy SQL string.
    ==> $where = "$src_table.post_type = '$post_type'" . ( $where ? " AND ( $where )" : "" );

    Fixing these three made the stuff work.
    Do you plan a bugfix release about this?
    (I’m asking to know how I should personally manage the issue)

    Related question:
    when a content is created, a HTTP 201 is returned and returned JSON contains the new data *including the custom field*.
    I don’t understand how the update_callback could define the value given to the returned custom field.

    Thread Starter drzraf

    (@drzraf)

    ^^ applies with patch -R, sorry

    Hi
    trunk/ (1.5.2) did the trick,
    I don’t really know how, I don’t know if wordpress is buggy in this regards, but it works (the theme is properly setup without my workaround in the core theme.php
    As a side request, please could you tag this version if no regression happen ?

    Thanks a lot DeannaS.

    PS: you may be interested by the attachement of this post
    (http://lists.automattic.com/pipermail/wp-hackers/2010-April/031637.html) for widgets automatic instanciation
    (though can’t find the attachment through archive)

    About the theme, the problem sits in switch_theme that NBD uses, and more precisely in the caching of option while WP_INSTALLING is defined.
    More explanation there :
    http://lists.automattic.com/pipermail/wp-hackers/2010-March/031075.html

    As a workaround, I added :

    if(defined('WP_INSTALLING')) {
      wp_cache_delete('template', 'options');
      wp_cache_delete('stylesheet', 'options');
    }

    in wp-includes/theme.php in switch_theme(), after delete_option(‘current_theme’);

    Another problem, the default values of :

    • oEmbed media height: a default NULL value > 0px is used instead of WP one: 600
    • why add a distinct theme option and do it per-blog ? what is it useful for ?
      A get_site_option(‘cets_blog_defaults_options’)[“default_theme”] wouldn’t be enough ?
    • please use the same default settings from ../wp-admin/includes/schema.php in the plugins default ones 🙂

    Thanks for your all your work !

Viewing 11 replies - 16 through 26 (of 26 total)