@@ -742,11 +742,11 @@ private function fetch_shared_network_snippets() {
742742 $ shared_snippets = $ wpdb ->get_results ( $ wpdb ->prepare ( $ sql , $ ids ), ARRAY_A );
743743
744744 foreach ( $ shared_snippets as $ index => $ snippet ) {
745- $ snippet = new Snippet ( $ snippet );
746- $ snippet ->network = true ;
745+ $ snippet = new Snippet ( $ snippet );
746+ $ snippet ->network = true ;
747747 $ snippet ->shared_network = true ;
748- $ snippet ->tags = array_merge ( $ snippet ->tags , array ( 'shared on network ' ) );
749- $ snippet ->active = in_array ( $ snippet ->id , $ active_shared_snippets );
748+ $ snippet ->tags = array_merge ( $ snippet ->tags , array ( 'shared on network ' ) );
749+ $ snippet ->active = in_array ( $ snippet ->id , $ active_shared_snippets );
750750
751751 $ shared_snippets [ $ index ] = $ snippet ;
752752 }
@@ -774,9 +774,11 @@ public function prepare_items() {
774774 $ snippets = array_fill_keys ( $ this ->statuses , array () );
775775
776776 /* Fetch all snippets */
777- if ( is_multisite () && ! $ this ->is_network ) {
778- $ local_snippets = get_snippets ( array (), false );
777+ if ( is_multisite () && ! $ this ->is_network && code_snippets_get_setting ( 'general ' , 'show_network_snippets ' ) ) {
779778 $ network_snippets = get_snippets ( array (), true );
779+ $ network_snippets = array_filter ( $ network_snippets , array ( $ this , 'exclude_shared_network_snippets ' ) );
780+
781+ $ local_snippets = get_snippets ( array (), false );
780782 $ snippets ['all ' ] = array_merge ( $ local_snippets , $ network_snippets );
781783 } else {
782784 $ snippets ['all ' ] = get_snippets ( array () );
@@ -896,6 +898,19 @@ public function prepare_items() {
896898 ) );
897899 }
898900
901+ /**
902+ * Callback for array_filter() to exclude shared network snippets from the
903+ *
904+ * @ignore
905+ *
906+ * @param Snippet $snippet The current snippet item being filtered
907+ *
908+ * @return bool false if the snippet is a shared network snippet
909+ */
910+ private function exclude_shared_network_snippets ( $ snippet ) {
911+ return ! $ snippet ->shared_network ;
912+ }
913+
899914 /**
900915 * Callback for usort() used to sort snippets
901916 *
0 commit comments