Note that there are some explanatory texts on larger screens.

plurals
  1. POphp: modifing object properties with a matching array
    primarykey
    data
    text
    <p>I need to modify properties of an object (a Wordpress object) and I would like to do it by using a matching array of values. </p> <p>Wordpress Object</p> <pre><code>array(9) { ["post"]=&gt; object(stdClass)#120 (25) { ["labels"]=&gt; object(stdClass)#123 (12) { ["name"]=&gt; string(5) "Posts" ["singular_name"]=&gt; string(4) "Post" ["add_new"]=&gt; string(7) "Add New" ["add_new_item"]=&gt; string(12) "Add New Post" ["edit_item"]=&gt; string(9) "Edit Post" ["new_item"]=&gt; string(8) "New Post" ["view_item"]=&gt; string(9) "View Post" ["search_items"]=&gt; string(12) "Search Posts" ["not_found"]=&gt; string(15) "No posts found." ["not_found_in_trash"]=&gt; string(24) "No posts found in Trash." ["parent_item_colon"]=&gt; NULL ["menu_name"]=&gt; string(5) "Posts" } ["description"]=&gt; string(0) "" ["publicly_queryable"]=&gt; bool(true) ["exclude_from_search"]=&gt; bool(false) ["capability_type"]=&gt; string(4) "post" ["map_meta_cap"]=&gt; bool(true) ["_builtin"]=&gt; bool(true) ["_edit_link"]=&gt; string(16) "post.php?post=%d" ["hierarchical"]=&gt; bool(false) ["public"]=&gt; bool(true) ["rewrite"]=&gt; bool(false) ["has_archive"]=&gt; bool(false) ["query_var"]=&gt; bool(false) ["register_meta_box_cb"]=&gt; NULL ["taxonomies"]=&gt; array(0) { } ["show_ui"]=&gt; bool(true) ["menu_position"]=&gt; NULL ["menu_icon"]=&gt; NULL ["permalink_epmask"]=&gt; int(1) ["can_export"]=&gt; bool(true) ["show_in_nav_menus"]=&gt; bool(true) ["show_in_menu"]=&gt; bool(true) ["name"]=&gt; string(4) "post" ["cap"]=&gt; object(stdClass)#122 (14) { ["edit_post"]=&gt; string(9) "edit_post" ["read_post"]=&gt; string(9) "read_post" ["delete_post"]=&gt; string(11) "delete_post" ["edit_posts"]=&gt; string(10) "edit_posts" ["edit_others_posts"]=&gt; string(17) "edit_others_posts" ["publish_posts"]=&gt; string(13) "publish_posts" ["read_private_posts"]=&gt; string(18) "read_private_posts" ["read"]=&gt; string(4) "read" ["delete_posts"]=&gt; string(12) "delete_posts" ["delete_private_posts"]=&gt; string(20) "delete_private_posts" ["delete_published_posts"]=&gt; string(22) "delete_published_posts" ["delete_others_posts"]=&gt; string(19) "delete_others_posts" ["edit_private_posts"]=&gt; string(18) "edit_private_posts" ["edit_published_posts"]=&gt; string(20) "edit_published_posts" } ["label"]=&gt; string(5) "Posts" } etc..., etc..., } </code></pre> <p>Array of values to be changed</p> <pre><code>$newpost = array( 'post' =&gt; array ( 'labels' =&gt; array( 'name' =&gt; 'News', 'singular_name' =&gt; 'News', 'add_new' =&gt; 'Add New', 'add_new_item' =&gt; 'Add New News', 'edit_item' =&gt; 'Edit News', 'new_item' =&gt; 'New News', 'view_item' =&gt; 'View News', 'search_items' =&gt; 'Search News', 'not_found' =&gt; 'No news found', 'not_found_in_trash' =&gt; 'No news found in Trash', 'parent_item_colon' =&gt; '', 'menu_name' =&gt; 'News' ), 'menu_icon' =&gt; get_bloginfo( 'template_url' ).'/template/cup.png', ) ); </code></pre> <p>Is this possible?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload