Forum Replies Created

Viewing 15 replies - 31 through 45 (of 95 total)
  • Thread Starter Rhapsody348

    (@rhapsody348)

    Thank you Marko.

    For the benefit of other multisite users, the answer is on the settings page there is a check box near the bottom to disable the option “Use singe configuration for all sites”.

    I am marking this topic resolved

    Thread Starter Rhapsody348

    (@rhapsody348)

    David,

    I just installed the 3.10 update that includes the updates you had in the development version I was testing.

    Question – Do I need to uninstall and reinstall the MLA Multisite Extensions after the 3.10 update? The MLA Multisite Extensions are listed as version 1.13.

    Thread Starter Rhapsody348

    (@rhapsody348)

    David,

    I have tested the MLA Multisite Extensions development version where you added the functions and shortcodes to copy multisite settings and media terms. These were in the MLA Multisite Extensions development version 20230708. I tested both a new site setup and copying the settings and terms to selected sites that already exist. I can report that these work great so you may incorporate the development version into your next full release. Thanks for taking the time to do this!

    Thread Starter Rhapsody348

    (@rhapsody348)

    I was able to code my own fix. Thanks.

    Thread Starter Rhapsody348

    (@rhapsody348)

    David – I have confirmed that my plugin is causing the problem. I haven’t located where yet but by inactivating it, the header is displayed properly. I will mark this thread as resolved.

    Thread Starter Rhapsody348

    (@rhapsody348)

    David,

    I have updated to the latest development version and successfully used it to copy Media categories from a “Master Site” to subsites. It works exactly as expected. I will take some time over the next week to review the documentation tab.

    Nice work & Thanks!

    Thread Starter Rhapsody348

    (@rhapsody348)

    Vladimir,

    Thanks for the explanation on the “Change role” belonging to WordPress. I will handle that using CSS on the user profile page too.

    I have marked this topic resolved.

    Thread Starter Rhapsody348

    (@rhapsody348)

    I don’t know if using css is the best approach but I modified the code you provided and have hidden the “Change to role …” and the associated “Change” button. This is the modified code.

    /*
     * Hides "Grant Roles" button, "Add Role", "Revoke Role" URE UI controls at Users list page 
     */
    add_filter('ure_bulk_grant_roles', 'ure_bulk_grant_roles');
    
    function ure_bulk_grant_roles( $show ) {
    
        $lib = URE_Lib::get_instance();
        if ($lib->is_super_admin()) {
            // do not hide for superadmin
            return $show;
        }
    
            echo '<style>
        		#new_role, #new_role2, #changeit, #changeit2 { display: none; }
        	</style>';
    
        return false;
    }
    Thread Starter Rhapsody348

    (@rhapsody348)

    Thanks Vladimir! This is almost there. The dropdown for “Change role to …” is still showing and I would like to hide that also.

    Thread Starter Rhapsody348

    (@rhapsody348)

    David,

    I did testing this weekend and found everything working well. The “All Sites” checkbox meets the need, so I won’t send the JS code for the check box manipulation.

    I was able to generate PHP code that allowed me to copy the media categories and tags from the original site to the subsite. I only handle Media Categories and Att. Tags as listed on your General Setting tab in the section Taxonomy Support. I pasted the code in two sections below. The first section contains two functions. The first function loads an array from the source site with all the Media Categories and Att. Tags so it may be used in the second function to copy (insert) these into the target site. You will see that I handle site switching in the 2nd function and always return on the original site the routine was entered with.

    /****************************************************************
    * function get_media_cats_tags()
    * gets the categories and tags assigned by the MLA plugin used 
    * to organize media and returns an array that may be iterated for individual
    * terms and taxonomies
    * items in the array needed for copying to another site are:
    	wp_term_taxonomy => taxonomy = 'attachment_category' or 'attachment_tag'
    	wp_term_taxonomy => term_id = int on the source (created when inserted)
    	wp_term_taxonomy => description = descriptive text of term
    	wp_term_taxonomy => parent = parent term_taxonomy_id if tiered, 0 otherwise
    	wp_terms => name = text displayed as friendly name for term
    	wp_terms => slug = slug for a particular term
    	wp_terms => term_group = int, usually 0
    	wp_term_taxonomy => term_taxonomy_id = int key auto generated when inserted
    	wp_terms => term_id = int key auto generated when inserted, used to relate
    	            wp_terms and wp_term_taxonomy
    *****************************************************************/
    function get_media_cats_tags() {
    $tags = get_terms( array(
        'taxonomy'   =>'attachment_tag',
        'hide_empty' => false,
    ) );
    
    if (is_wp_error( $tags )) $tags = array();
    
    $cats = get_terms( array(
        'taxonomy'   => 'attachment_category',
        'hide_empty' => false,
    ) );
    
    if (is_wp_error( $cats )) $cats = array();
    
    //combine the media categories and tags arrays and return the combined array
    return array_merge($cats, $tags);	
    
    } // end function get_media_cats_tags()
    /*****************************************************************
    * function copy_media_cats_tags(array $media_cats_tags, int $target_site)
    * copies the media categories and tags passed in an array 
    * (use function get_media_cats_tags() for input) and creates on the target
    * site.
    * 1. if multisite, iterate through array and do the following on target_site:
    * 2. register_taxonomy_for_object_type( string $taxonomy, string $object_type )
    *    $object_type is 'attachment' for media
    * 3. wp_insert_term( string $term, string $taxonomy, array|string $args = array() )
    * 4. return to the original site
    ******************************************************************/
    function copy_media_cats_tags($media_cats_tags, $target_site) {
    
    if (is_multisite()) foreach ($media_cats_tags as $single) {
    	
    	$parent_slug = null; // initialize
    	
    	$parent_term_id = 0; // default for no parent
    
    	$site_id = get_current_blog_id(); // gets current site blog id
    
    	switch_to_blog( $target_site ); // selects the target blog
    
    
    //register the taxonomy if it does not already exist
    	if (!taxonomy_exists( $single->taxonomy )) register_taxonomy_for_object_type( $single->taxonomy, 'attachment' );
    
    //store and array of slugs in order to look up parent if needed
    	$slugs[$single->term_id] = $single->slug;
    
    // check if the term has a parent, if so need the inserted parent
    //get the original parent slug to be used for looking up inserted taxonomy
    	if ($single->parent > 0) {
    		$parent_slug = $slugs[$single->parent];
    
    //get the new inserted term as an object
    		$inserted_term = get_term_by( 'slug', $parent_slug, $single->taxonomy, $output = OBJECT, $filter = 'raw' );
    
    //extract the inserted term_id for parent
    		if ($inserted_term) $parent_term_id = $inserted_term->term_id;
    
    	} // end if ($single->parent > 0)
    		
    	$args = array(
    		'description' => $single->description,
    		'slug' => $single->slug,
    		'parent' => $parent_term_id,
    	);
    
    //insert the term if it does not already exist
    	if (!term_exists( $single->name, $single->taxonomy ) ) wp_insert_term( $single->name, $single->taxonomy, $args );
    
    } // end foreach ($media_cats_tags as $single)
    
    if (is_multisite()) switch_to_blog( $site_id ); // return to original site 
    	
    } // end copy_media_cats_tags($media_cats_tags, $target_site)
    

    Below is test code I used to force the desired subsite for testing. This could be handled in your iterative loop you have that copies the settings to each selected site where the site_id is changed.

    /***** code for testing media cats & tags copy ***/
    	$media_cats_tags = get_media_cats_tags();
    
    	if (is_multisite()) $target_id = 72; // kai site for testing
    
    	copy_media_cats_tags($media_cats_tags, $target_id);
    /*****^^^^^ code for testing media cats & tags copy ^^^^***/
    Thread Starter Rhapsody348

    (@rhapsody348)

    Thanks for the update David. I just installed the Development Version and have started to play with it. I’ll do so over the upcoming weekend and post comments here.

    Two initial comments:
    1. I’m using my test server that only has 6 subsites. Checking the boxes to update sites is no problem. On my production multisite installation there are about a hundred subsites. Including master “Check All” / “Uncheck All” buttons would be helpful. I have embedded JS code on my plugin to do this and will send you that code at the end of the weekend after my testing.
    2. It would be helpful to have an option to copy any media categories under the Organize Media that are on the site to be copied. I have some PHP code I will send you that is in my plugin that does this for when I use my plugin to copy a media item from one subsite to another subsite and will also send you this code.

    Thread Starter Rhapsody348

    (@rhapsody348)

    David – no problem and thanks for considering. I may be able to provide some code already used for my multisite application to make this easier for you. I created some PHP routines that copy saved options settings from the master site to subsites. What I don’t have is an understanding of all the settings MLA stores, and which settings should be transferred. If you could provide the relevant saved option names (e.g. mla_custom_field_mapping, …) and whether there are particular options in the array that should NOT be transferred, I may be able to assist.

    It’s a busy time as I get my boat ready for the sailing season, but when I do get a chance can send you some annotated PHP files and descriptions. Do you have a preferred place I can transfer the files? (FTP site, Dropbox, Google drive, Email, etc.)

    Rhapsody348

    (@rhapsody348)

    sorry – duplicate post so I deleted this

    Rhapsody348

    (@rhapsody348)

    See my old post at this link on how you may modify the ai1ec files to stop the error. Time.ly is using an older version of iCalcreator and needs to use the latest version to stop theses errors.

    https://www.ads-software.com/support/topic/solution-for-stopping-ai1ec-creating-error-log-entries/

    Thread Starter Rhapsody348

    (@rhapsody348)

    I can confirm that this now works in the latest release. Thanks!

Viewing 15 replies - 31 through 45 (of 95 total)