diff --git a/docker/wordpress/plugins/mu-plugins/apps.svg b/docker/wordpress/plugins/mu-plugins/apps.svg new file mode 100644 index 0000000..2297805 --- /dev/null +++ b/docker/wordpress/plugins/mu-plugins/apps.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docker/wordpress/plugins/mu-plugins/assets/admin-bar-style.php b/docker/wordpress/plugins/mu-plugins/assets/admin-bar-style.php new file mode 100644 index 0000000..17d3ea8 --- /dev/null +++ b/docker/wordpress/plugins/mu-plugins/assets/admin-bar-style.php @@ -0,0 +1,438 @@ + + /*estilos admin menu*/ + #adminmenu, #adminmenu .wp-submenu, #adminmenuback, #adminmenuwrap { + background-color: '. $bg_color .'!important; + } + #adminmenu li { + border-bottom: 1px solid '. $secondary .'; + /*border-right: 1px solid #262626;*/ + } + #adminmenu li.wp-menu-separator { + padding-top: 6px; + margin: 0; + border-bottom: 0; + } + #adminmenu li.wp-menu-separator .separator, { + border-bottom: 1px solid '. $secondary .'; + } + /*#adminmenu li.wp-has-current-submenu + li.wp-menu-separator, + #adminmenu li:hover + li.wp-menu-separator { + background-color: '. $secondary .'!important; + }*/ + #adminmenu li:hover div.wp-menu-image:before, + #adminmenu li a:hover { + color: '. $primary .'; + } + #adminmenu li.wp-not-current-submenu:hover > a, + #adminmenu li:hover > a { + background-color: '. $secondary .'!important; + } + + #adminmenu li.wp-has-current-submenu div.wp-menu-image:before { + color: '. $primary .'!important; + } + + #adminmenu a { + font-size: 16px!important + } + #adminmenu a, + #adminmenu div.wp-menu-image:before { + color: #262626!important; + } + #adminmenu a:hover, + #adminmenu a:hover div.wp-menu-image:before, + #adminmenu li:hover { + color: '. $primary .'!important; + } + + /*#adminmenu .wp-has-current-submenu { + border-right: 1px solid #262626; + }*/ + #adminmenu .wp-has-current-submenu>a { + color: '. $primary .'!important; + background-color: '. $secondary .'!important; + } + #adminmenu .wp-has-current-submenu .wp-submenu { + padding: 0!important; + background-color: '. $secondary .'!important; + } + #adminmenu .wp-has-current-submenu .wp-submenu li a { + padding-top: 10px; + padding-bottom: 10px; + font-size: 14px !important; + } + ul#adminmenu a.wp-has-current-submenu:after, + ul#adminmenu>li.current>a.current:after, + ul#adminmenu a.wp-not-current-submenu:after { + border-right-color: '. $primary .'!important; + /*right: -1px; + border-width: 9px;*/ + } + /*ul#adminmenu a.wp-has-current-submenu:after, + ul#adminmenu>li.current>a.current:after, + ul#adminmenu a.wp-not-current-submenu:after, + #adminmenu .wp-has-submenu:after { + border-right-color: '. $primary .'!important; + /*right: -1px; + border-width: 9px;*/ + }*/ + #adminmenu li.wp-has-submenu.wp-not-current-submenu:hover:after { + border-right-color: '. $primary .'; + } + #adminmenu .wp-submenu li { + border-bottom: 0; + } + body.wp-admin #adminmenu li.wp-has-submenu.wp-not-current-submenu, + body.wp-admin #adminmenu li.wp-has-submenu.wp-not-current-submenu > a { + background-color: '. $bg_color .'!important; + } + body.wp-admin #adminmenu li.wp-has-submenu.wp-not-current-submenu:hover { + background-color: '. $secondary .'!important; + } + #adminmenu li.wp-has-submenu.wp-not-current-submenu .wp-submenu a { + color: #262626!important; + } + #adminmenu li.wp-has-submenu.wp-not-current-submenu .wp-submenu li a:hover { + color: '. $primary .'!important; + } + #collapse-button { + font-size: 14px; + margin-top: 10px; + } + #collapse-button:hover { + color: '. $primary .'; + opacity: 0.7; + } + #adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head, + #adminmenu .wp-not-current-submenu .wp-submenu .wp-submenu-head { + color: #262626; + /*font-size: 16px; + font-weight: bold;*/ + } + + #adminmenu .wp-has-submenu.wp-not-current-submenu.menu-top .wp-menu-name { + background-color: '. $bg_color .'!important; + } + #adminmenu .current.menu-top a, + #adminmenu .current.menu-top a .wp-menu-image:before { + color: '. $primary .'!important; + } + #adminmenu .wp-has-submenu.wp-not-current-submenu.menu-top .wp-menu-name:hover, + #adminmenu .wp-not-current-submenu.menu-top:hover { + background-color: '. $secondary .'!important; + } + #adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head, #adminmenu .wp-menu-arrow, #adminmenu .wp-menu-arrow div, #adminmenu li.current a.menu-top, #adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, .folded #adminmenu li.current.menu-top, .folded #adminmenu li.wp-has-current-submenu { + background-color: '. $secondary .'; + } + + + /*espacios*/ + html.wp-toolbar { + padding-top: 66px;/*mismo espacio que altura logo*/ + } + + /*admin bar*/ + #wpadminbar { + height: auto; + background-color: '. $bg_color .'; + padding: 0 30px; + border-bottom: 1px solid #000; + margin-bottom: 20px; + box-sizing: border-box; + } + + /* wp-logo*/ + #wpadminbar #wp-admin-bar-wp-logo > .ab-item { + width: 200px; + height: 66px; + display: flex; + padding: 0; + } + #wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon:before { + content: none; + } + #wpadminbar>#wp-toolbar>#wp-admin-bar-root-default .ab-icon { + background-image: url(' . $bg_logo . ') !important; + background-position: center; + background-repeat: no-repeat; + background-size: contain; + width: 100%; + height: 100%; + float: none; + padding: 0; + } + #wpadminbar .ab-top-menu>li.hover>.ab-item, + #wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus, + #wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item, + #wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus { + background-color: '. $bg_color .'!important; + } + + /*dropdown menu*/ + #wpadminbar .fas, + #wpadminbar .far { + font-family: "Font Awesome 5 Free"!important; + } + #wpadminbar .fa { + font-family: "FontAwesome"; + } + #wpadminbar .fab { + font-family: "Font Awesome 5 Brands" + } + #wpadminbar .ab-top-menu #wp-admin-bar-dropdown-menu.menupop .ab-sub-wrapper { + min-width: 350px; + height: 500px; + overflow-y: scroll; + } + #wpadminbar #wp-admin-bar-dropdown-menu { + display: flex; + height: 66px; + align-items: center; + margin-right: 40px; + } + #wpadminbar #wp-admin-bar-dropdown-menu > .ab-item { + background-image: url(' . WPMU_PLUGIN_URL . '/apps.svg); + background-repeat: no-repeat; + background-size: contain; + width: 38px; + height: 38px; + padding: 0; + cursor: pointer; + } + #wpadminbar #wp-admin-bar-dropdown-menu #wp-admin-bar-menu-apps ul { + display: flex; + flex-wrap: wrap; + padding-top: 20px; + } + #wpadminbar #wp-admin-bar-dropdown-menu #wp-admin-bar-menu-apps ul > li { + text-align: center; + width: 33%; + padding: 0 20px 0; + margin: 0 0 25px; + box-sizing: border-box; + } + #wpadminbar #wp-admin-bar-dropdown-menu #wp-admin-bar-menu-apps ul > li > a { + min-width: auto; + padding: 0; + height: 100%; + } + #wpadminbar #wp-admin-bar-dropdown-menu #wp-admin-bar-menu-apps ul > li > a .icon { + width: 48px; + margin: auto; + background-color: #92AC22; + border-radius: 4px; + height: 48px; + } + #wpadminbar #wp-admin-bar-dropdown-menu #wp-admin-bar-menu-apps ul > li > a .icon i { + font-size: 22px; + line-height: 48px; + color: white; + } + #wpadminbar #wp-admin-bar-dropdown-menu #wp-admin-bar-menu-apps hr { + width: 310px; + margin: 0 auto 20px; + } + #wpadminbar #wp-admin-bar-dropdown-menu #wp-admin-bar-menu-apps ul > li > a .text { + font-size: 16px; + font-weight: 300; + line-height: 1.1em; + margin-top: 5px; + } + #wpadminbar #wp-admin-bar-dropdown-menu #wp-admin-bar-menu-apps ul > li > a.ab-item { + white-space: break-spaces; + } + + /*notificaciones*/ + #wpadminbar #wp-admin-bar-notifications { + display: flex; + height: 66px; + align-items: center; + margin-right: 40px; + } + #wpadminbar #wp-admin-bar-notifications > .ab-item { + background-image: url(' . WPMU_PLUGIN_URL . '/bell.svg); + background-repeat: no-repeat; + background-size: contain; + width: 32px; + height: 32px; + padding: 0; + cursor: pointer; + } + /*counter*/ + #wpadminbar #wp-admin-bar-notifications .counter { + position: absolute; + top: 10px; + right: -13px; + background-color: red; + width: 20px; + height: 22px; + border-radius: 6px; + color: white; + font-size: 10px; + text-align: center; + line-height: 22px; + } + + /*mis sitios*/ + #wpadminbar #wp-admin-bar-my-sites { + display: flex; + height: 66px; + align-items: center; + margin-left: 30px; + } + #wpadminbar #wp-admin-bar-my-sites a, + #wpadminbar #wp-admin-bar-my-sites a:before { + color: #262626!important; + } + #wpadminbar #wp-admin-bar-my-sites .ab-sub-wrapper a:hover, + #wpadminbar #wp-admin-bar-my-sites .ab-sub-wrapper a:hover:before { + color: '. $primary .'!important; + background-color: '. $secondary.'; + } + #wpadminbar #wp-admin-bar-my-sites a.ab-item:before { + top: 0; + font-size: 32px; + line-height: 66px; + padding: 0; + } + #wpadminbar #wp-admin-bar-my-sites a.ab-item { + height: 66px; + line-height: 66px; + font-size: 16px; + } + #wpadminbar .menupop .menupop>.ab-item .wp-admin-bar-arrow:before { + line-height: 50px; + padding: 0; + top: 0; + } + #wpadminbar .ab-sub-wrapper li.menupop { + height: 50px; + line-height: 50px; + background-color: '. $bg_color .'; + } + #wpadminbar .quicklinks .menupop ul.ab-sub-secondary, + #wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu { + background-color: '. $bg_color .'!important; + } + #wpadminbar .ab-sub-wrapper li.menupop a.ab-item { + height: 50px!important; + line-height: 50px!important; + } + #wpadminbar .ab-sub-wrapper li.menupop a.ab-item:hover { + color: '. $primary .'!important; + + } + #wpadminbar .ab-sub-wrapper .ab-submenu { + padding: 0; + } + #wpadminbar .ab-top-menu .menupop .ab-sub-wrapper .ab-sub-wrapper { + top: 30px!important; + } + #wpadminbar .quicklinks li .blavatar:before { + color: #262626!important; + } + #wpadminbar .quicklinks li a:hover .blavatar:before { + color: '. $primary .'!important; + background-color: '. $secondary.'; + } + + /*usuario*/ + #wpadminbar #wp-admin-bar-my-account { + display: flex; + height: 66px; + align-items: center; + margin-right: 40px; + } + + #wpadminbar .ab-top-menu .menupop .ab-sub-wrapper, + #wpadminbar .ab-top-secondary .menupop .ab-sub-wrapper { + top: 66px; + background: '. $bg_color. '; + } + + #wpadminbar .ab-top-secondary .menupop .ab-sub-wrapper a { + color: #262626!important; + } + #wpadminbar .ab-top-secondary .menupop .ab-sub-wrapper a:hover { + color: '. $primary .'!important; + background-color: '. $secondary.'; + } + + #wpadminbar .ab-top-secondary #wp-admin-bar-dropdown-menu .ab-sub-wrapper a:hover { + background-color: transparent; + } + + #wpadminbar #wp-admin-bar-my-account > .ab-item { + padding: 0; + height: auto; + } + + #wpadminbar #wp-admin-bar-my-account.with-avatar > .ab-item img { + border: 0; + height: 42px; + width: 42px; + border-radius: 90px; + } + + @media screen and (max-width: 782px) { + html #wpadminbar { + height: 70px; + /*position: fixed;*/ + } + .wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-item { + background-color: '. $bg_color .'; + } + .wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { + color: '. $primary .'; + } + #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { + line-height: 66px; + color: #000; + } + #wpadminbar #wp-admin-bar-menu-toggle a { + height: 66px; + } + #wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a img { + height: 50px; + width: 50px; + top: 10px; + right: 0; + } + #wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a { + height: 66px; + } + #wpadminbar #wp-admin-bar-my-account { + margin-right: 20px; + } + #wpadminbar #wp-admin-bar-user-info .display-name { + color: #000; + } + #wpadminbar .ab-top-menu>.menupop>.ab-sub-wrapper .ab-item { + padding: 0 16px; + } + #wpadminbar .ab-top-menu .menupop .ab-sub-wrapper .ab-sub-wrapper { + top: 50px!important; + } + + } + @media screen and (max-width: 620px) { + #wpadminbar #wp-admin-bar-wp-logo > .ab-item { + max-width: 180px; + } + } + @media screen and (max-width: 600px) { + #wpbody { + padding-top: 0; + } + html #wpadminbar { + position: fixed; + } + .auto-fold #adminmenu { + top: 0; + } + + } + + + '; \ No newline at end of file diff --git a/docker/wordpress/plugins/mu-plugins/assets/encabezamiento-1.png b/docker/wordpress/plugins/mu-plugins/assets/encabezamiento-1.png new file mode 100644 index 0000000..723d87f Binary files /dev/null and b/docker/wordpress/plugins/mu-plugins/assets/encabezamiento-1.png differ diff --git a/docker/wordpress/plugins/mu-plugins/assets/style.css b/docker/wordpress/plugins/mu-plugins/assets/style.css new file mode 100644 index 0000000..08fca54 --- /dev/null +++ b/docker/wordpress/plugins/mu-plugins/assets/style.css @@ -0,0 +1,6 @@ +body.page.singular header.entry-header { + display: none; + border: 0; + padding: 0; + margin: 0; +} \ No newline at end of file diff --git a/docker/wordpress/plugins/mu-plugins/assets/style.php b/docker/wordpress/plugins/mu-plugins/assets/style.php new file mode 100644 index 0000000..e69de29 diff --git a/docker/wordpress/plugins/mu-plugins/bell.svg b/docker/wordpress/plugins/mu-plugins/bell.svg new file mode 100644 index 0000000..cc51fa8 --- /dev/null +++ b/docker/wordpress/plugins/mu-plugins/bell.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docker/wordpress/plugins/mu-plugins/custom-logo-admin-bar.png b/docker/wordpress/plugins/mu-plugins/custom-logo-admin-bar.png new file mode 100644 index 0000000..4d670da Binary files /dev/null and b/docker/wordpress/plugins/mu-plugins/custom-logo-admin-bar.png differ diff --git a/docker/wordpress/plugins/mu-plugins/helper-developer.php b/docker/wordpress/plugins/mu-plugins/helper-developer.php new file mode 100644 index 0000000..6c3d537 --- /dev/null +++ b/docker/wordpress/plugins/mu-plugins/helper-developer.php @@ -0,0 +1,16 @@ +'; + print_r( $string ); + echo ''; +} \ No newline at end of file diff --git a/docker/wordpress/plugins/mu-plugins/templates/encabezado.json b/docker/wordpress/plugins/mu-plugins/templates/encabezado.json new file mode 100644 index 0000000..91c4751 --- /dev/null +++ b/docker/wordpress/plugins/mu-plugins/templates/encabezado.json @@ -0,0 +1,5 @@ +{ + "__file": "wp_block", + "title": "Encabezado", + "content": "\n\n

Título de la página

\n\n\n\n\n

Empieza a escribir aquí el contenido de la página. Puedes incluir imágenes y links

\n" +} \ No newline at end of file diff --git a/docker/wordpress/plugins/mu-plugins/wemcor-admin-bar.php b/docker/wordpress/plugins/mu-plugins/wemcor-admin-bar.php new file mode 100644 index 0000000..8920383 --- /dev/null +++ b/docker/wordpress/plugins/mu-plugins/wemcor-admin-bar.php @@ -0,0 +1,418 @@ + 'top-secondary', + 'id' => 'notifications', + 'title' => false, + 'href' => false, + 'meta' => array( + 'onclick' => 'open-notifications', + 'class' => 'notifications', + 'html' => '0' + ) + ); + $admin_bar->add_node( $args ); + + $html = html_menu_apps(); + + //apps + $args = array( + 'parent' => 'top-secondary', + 'id' => 'dropdown-menu', + 'title' => false, + 'href' => false, + 'meta' => array( + 'onclick' => 'openDropDown', + 'class' => 'dropdown-menu menupop', + 'html' => $html + ) + ); + $admin_bar->add_node( $args ); + +} + +//borramos todos los items de admin bar excepto logo y usuario que lo modificaremos posteriormente. De esta forma prevenimos la carga de ítems extras colocados por otros plugins que s epuedan instalar en un futuro +add_action( 'wp_before_admin_bar_render', 'wemcor_remove_menu_admin_bar', PHP_INT_MAX ); +function wemcor_remove_menu_admin_bar() { + global $wp_admin_bar; + + //JSON + $path_json = wemcor_get_url_json(); + $json = file_get_contents($path_json); + $json_data = json_decode($json, true); + + $no_clear_menus = array( + 'wp-logo', + 'my-account', + 'my-sites', + 'menu-toggle', + 'notifications', + 'dropdown-menu' + ); + + $all_menus = $wp_admin_bar->get_nodes(); + check_nodes($no_clear_menus, $all_menus); + + $user_id = get_current_user_id(); + $user_data = get_user_by( 'id', $user_id ); + $user_name = $user_data->display_name; + + $my_account = $wp_admin_bar->get_node( 'my-account' ); + if($my_account) { + /*stdClass Object( + [id] => my-account + [title] => Hola, gestor + [parent] => top-secondary + [href] => http://test.wemcor.es/wp-admin/network/profile.php + [group] => + [meta] => Array( + [class] => with-avatar + ) + )*/ + + if( isset($json_data['user']['avatar']) ) $user_avatar = ''; + else $user_avatar = get_avatar($user_id); + if( isset($json_data['user']['account']) ) $user_account = $json_data['user']['account']; + else $user_account = $my_account->href; + $wp_admin_bar->add_node( + array( + 'parent' => $my_account->parent, + 'id' => $my_account->id, + 'title' => $user_avatar, + 'href' => $user_account, + 'group' => $my_account->group, + 'meta' => $my_account->meta + ) + ); + + } + + $my_avatar = $wp_admin_bar->get_node( 'user-info' ); + if($my_avatar) { + /*stdClass Object( + [id] => user-info + [title] => 'wp-manager' + [parent] => user-actions + [href] => https://wp.montseny.digitaldemocratic.net/wp-admin/profile.php + [group] => + [meta] => Array( + [tabindex] => -1 + ) + )*/ + if( isset($json_data['user']['avatar']) ) $user_avatar = ''.$user_name.''; + else $user_avatar = ''.$user_name.''; + if( isset($json_data['user']['account']) ) $user_account = $json_data['user']['account']; + else $user_account = $my_account->href; + $wp_admin_bar->add_node( + array( + 'id' => $my_avatar->id, + 'title' => $user_avatar, + 'parent' => $my_avatar->parent, + 'href' => $user_account, + 'group' => $my_avatar->group, + 'meta' => $my_avatar->meta + ) + ); + } + + $my_profile = $wp_admin_bar->get_node( 'edit-profile' ); + if($my_profile) { + /*stdClass Object( + [id] => edit-profile + [title] => Edit Profile + [parent] => user-actions + [href] => https://wp.montseny.digitaldemocratic.net/wp-admin/profile.php + [group] => + [meta] => Array() + )*/ + if( isset($json_data['user']['account']) ) $user_account = $json_data['user']['account']; + else $user_account = $my_account->href; + $wp_admin_bar->add_node( + array( + 'id' => $my_profile->id, + 'title' => $my_profile->title, + 'parent' => $my_profile->parent, + 'href' => $user_account, + 'group' => $my_profile->group, + 'meta' => $my_profile->meta + ) + ); + } + +} + +function check_nodes($no_clear_menus, $all_menus) { + global $wp_admin_bar; + + foreach( $all_menus as $menu ) { + + $remove_node = false; + + if( in_array($menu->id, $no_clear_menus) ) continue; + + if( in_array($menu->parent, $no_clear_menus) && $menu->parent != 'wp-logo' ) continue; + + if( empty($menu->parent) && $menu->id == 'top-secondary' ) continue; + + if( empty($menu->parent) || $menu->parent == 'top-secondary' || $menu->parent == 'wp-logo' ) $remove_node = true; + + if( !$remove_node ) { + $parent_node = $wp_admin_bar->get_node($menu->parent); + $parent_node_parent = $parent_node->parent; + $remove_node = check_parents($parent_node_parent, $no_clear_menus); + } + + if( $remove_node ) $wp_admin_bar->remove_menu( $menu->id ); + + } + +} + +function check_parents( $parent, $no_clear_menus ) { + global $wp_admin_bar; + $node = $wp_admin_bar->get_node($parent); + + if( in_array($node->id, $no_clear_menus) && $node->id != 'wp-logo' ) return false; + + if( in_array($node->parent, $no_clear_menus) && $node->parent != 'wp-logo' ) return false; + + if( empty($node->parent) || $node->parent == 'top-secondary' || $node->parent == 'wp-logo' ) return true; + + $parent_node = $wp_admin_bar->get_node($menu->parent); + $parent_node_parent = $parent_node->parent; + $remove_node = check_parents($parent_node_parent); + +} + +//estilos personalizados admin bar +add_action( 'wp_before_admin_bar_render', 'wemcor_custom_styles_admin_bar', 999 ); +function wemcor_custom_styles_admin_bar() { + //JSON + $path_json = wemcor_get_url_json(); + $json = file_get_contents($path_json); + $json_data = json_decode($json, true); + + if( isset($json_data['logo']) ) $bg_logo = $json_data['logo']; + else $bg_logo = WPMU_PLUGIN_URL . '/custom-logo-admin-bar.png'; + //$bg_logo = WPMU_PLUGIN_URL . '/custom-logo-admin-bar.png'; + + if( isset($json_data['colours']['background']) ) $bg_color = $json_data['colours']['secondary']; + else $bg_color = '#FFF'; + + if( isset($json_data['colours']['primary']) ) $primary = $json_data['colours']['primary']; + else $primary = '#262626'; + + if( isset($json_data['colours']['secondary']) ) $secondary = $json_data['colours']['background']; + else $secondary = '#f0f0f0'; + + require_once dirname(__FILE__) . '/assets/admin-bar-style.php'; + +} + +//encolamos javascript para funciones de menu toggle +add_action( 'admin_enqueue_scripts', 'wemcor_admin_enqueue_scripts' ); +add_action( 'wp_enqueue_scripts', 'wemcor_admin_enqueue_scripts' ); +function wemcor_admin_enqueue_scripts() { + + //FontAwesome 5 + //wp_enqueue_style('fontawesome', 'https://use.fontawesome.com/releases/v5.8.1/css/all.css', '', '5.8.1', 'all'); + + //FontAwesome 4 + wp_enqueue_style('fontawesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css', '', '4.7.0', 'all'); + +} + + +//HTML del menú de apps +function html_menu_apps() { + //JSON + $path_json = wemcor_get_url_json(); + $json = file_get_contents($path_json); + $json_data = json_decode($json, true); + + /* + Array( + [background_login] => https://api.montseny.digitaldemocratic.net/custom/img/background.png + [colours] => Array( + [background] => #F0F0F0 + [primary] => #92AE01 + [secondary] => #FFFFFF) + [logo] => https://api.montseny.digitaldemocratic.net/custom/img/logo.png + [apps_external] => Array( + [0] => Array( + [href] => https://agora.xtec.cat/ceipmontseny-barcelona/ + [icon] => fa fa-university + [name] => Escola Web + [shortname] => web + ) + [1] => Array( + [href] => https://youtube.com/ + [icon] => fa fa-youtube-play + [name] => Youtube + [shortname] => youtube) + [2] => Array( + [href] => https://www.wordreference.com/ + [icon] => fa fa-book + [name] => Diccionari + [shortname] => diccionari) + [3] => Array( + [href] => http://meet.jit.si/ + [icon] => fa fa-video-camera + [name] => Reunions Jitsi + [shortname] => jitsi) + [4] => Array( + [href] => https://www.google.es/ + [icon] => fa fa-search + [name] => Cercar + [shortname] => search) + [5] => Array( + [href] => https://www.google.es/maps/preview + [icon] => fa fa-map-marker + [name] => Maps + [shortname] => maps) + ) + [apps_internal] => Array( + [0] => Array( + [href] => https://nextcloud.montseny.digitaldemocratic.net/ + [icon] => fa fa-cloud + [name] => Núvol + crear arxius + [shortname] => cloud) + [1] => Array( + [href] => https://nextcloud.montseny.digitaldemocratic.net/apps/mail/setup + [icon] => fa fa-envelope-o + [name] => Correu + [shortname] => email) + [2] => Array( + [href] => https://pad.montseny.digitaldemocratic.net/ + [icon] => fa fa-file-text-o + [name] => Pads + [shortname] => pads) + [3] => Array( + [href] => https://nextcloud.montseny.digitaldemocratic.net/apps/forms + [icon] => fa fa-check-square-o + [name] => Formularis + [shortname] => forms) + [4] => Array( + [href] => https://nextcloud.montseny.digitaldemocratic.net/apps/polls + [icon] => fa fa-bar-chart + [name] => Enquestes + [shortname] => feedback) + [5] => Array( + [href] => https://nextcloud.montseny.digitaldemocratic.net/apps/spreed + [icon] => fa fa-commenting-o + [name] => Xat + [shortname] => chat) + [6] => Array( + [href] => https://nextcloud.montseny.digitaldemocratic.net/apps/calendar + [icon] => fa fa-calendar + [name] => Calendari + [shortname] => schedule) + [7] => Array( + [href] => https://wp.montseny.digitaldemocratic.net/wp-login.php?saml_sso + [icon] => fa fa-rss + [name] => Webs + [shortname] => webs) + [8] => Array( + [href] => https://nextcloud.montseny.digitaldemocratic.net/apps/bbb + [icon] => fa fa-video-camera + [name] => Reunions BBB + [shortname] => meets_bbb) + [9] => Array( + [href] => https://nextcloud.montseny.digitaldemocratic.net/apps/photos + [icon] => fa fa-file-image-o + [name] => Fotos + [shortname] => photos) + ) + [user] => Array( + [account] => https://sso.montseny.digitaldemocratic.net/auth/realms/master/account + [avatar] => https://sso.montseny.digitaldemocratic.net/auth/realms/master/avatar-provider + [password] => https://sso.montseny.digitaldemocratic.net/auth/realms/master/password + ) + ) +*/ + $html = ''; + if(isset($json_data['apps_external'])) $apps_external = $json_data['apps_external']; + if(isset($json_data['apps_internal'])) $apps_internal = $json_data['apps_internal']; + if(isset($json_data['apps_courses'])) $apps_courses = $json['apps_my_courses']; + + if( $apps_external || $apps_internal || $apps_courses ) $html .= '
'; + + //internals + if( $apps_internal ) { + $html .= ''; + } + + //externals + if( $apps_external ) { + if( $apps_internal ) $html .= '
'; + $html .= ''; + } + + //courses + if( $apps_courses ) { + if( $apps_internal || $apps_external) $html .= '
'; + $html .= ''; + } + + if( $apps_external || $apps_internal || $apps_courses ) $html .= '
'; + + + return $html; +} + +function wemcor_get_url_json() { + $path = str_replace('wp.', 'api.', DOMAIN_CURRENT_SITE); + return 'https://'.$path.'/json'; + +} + diff --git a/docker/wordpress/plugins/mu-plugins/wemcor-functions.php b/docker/wordpress/plugins/mu-plugins/wemcor-functions.php new file mode 100644 index 0000000..7728b75 --- /dev/null +++ b/docker/wordpress/plugins/mu-plugins/wemcor-functions.php @@ -0,0 +1,51 @@ +post_type ) $title = 'Nueva página'; + + return $title; +} + +// cargar contenido predeterminado cuando se hace click en añadir nueva página +add_filter( 'default_content', 'wemcor_default_content_on_page', 10, 2 ); +function wemcor_default_content_on_page( $content, $post ) { + if( 'page' === $post->post_type ) $content = ' + +

Título de la página

+ + + + +

Empieza a escribir aquí el contenido de la página. Puedes incluir imágenes y links

+'; + + return $content; +} \ No newline at end of file diff --git a/docker/wordpress/plugins/mu-plugins/wemcor-intranet.php b/docker/wordpress/plugins/mu-plugins/wemcor-intranet.php new file mode 100644 index 0000000..6e75b90 --- /dev/null +++ b/docker/wordpress/plugins/mu-plugins/wemcor-intranet.php @@ -0,0 +1,189 @@ +blog_id;// Object WP_Site + add_blog_option( $blog_id, 'wemcor-publicarweb', false ); +} + +/* + * Pestaña adicional en Site info + * + * Añadimos una pestaña de opciones en Site info (editar site) para disponer de la opción de publicar / despublicar site + * + */ +add_filter( 'network_edit_site_nav_links', 'wemcor_custom_siteinfo_tabs' ); +function wemcor_custom_siteinfo_tabs( $tabs ){ + + $tabs['site-wemcor'] = array( + 'label' => 'Publicar Web', + 'url' => 'sites.php?page=publicarweb', + 'cap' => 'manage_sites' + ); + return $tabs; + +} + +// Creamos menu en barra lateral +add_action( 'network_admin_menu', 'wemcor_page_publicar_web' ); +function wemcor_page_publicar_web() { + add_submenu_page( + 'sites.php', + 'Publicar Web', + 'Publicar Web', + 'manage_sites', + 'publicarweb', + 'callback_publicar_web' + ); +} + +// Mostrar página (callback function) +function callback_publicar_web() { + + $id = $_REQUEST['id']; + + $title = 'Publicar Web'; + $current_blog_details = get_blog_details( array( 'blog_id' => $id ) ); + $site_name = $current_blog_details->blogname; + + echo '

' . $title . '

+

Visitar | Escritorio

'; + + // navigation tabs + network_edit_site_nav( array( + 'blog_id' => $id, + 'selected' => 'site-wemcor' + ) ); + + //output HTML + echo ' + +
'; + wp_nonce_field( 'wemcor-check' . $id ); + + echo ' + + + + +
+
'; + + submit_button(); + echo '
'; + +} + +// Guardar opción en base de datos +add_action( 'network_admin_edit_publicarwebupdate', 'wemcor_save_publicar_web' ); +function wemcor_save_publicar_web() { + + $blog_id = $_POST['id']; + + check_admin_referer('wemcor-check'.$blog_id); + update_blog_option( $blog_id, 'wemcor-publicarweb', $_POST['wemcor-publicarweb'] ); + + wp_redirect( add_query_arg( array( + 'page' => 'publicarweb', + 'id' => $blog_id, + 'updated' => 'true'), network_admin_url('sites.php') + )); + //redirect to /wp-admin/sites.php?page=publicarweb&blog_id=ID&updated=true + + exit; +} + +// Notices +add_action( 'network_admin_notices', 'wemcor_notice' ); +function wemcor_notice() { + if( isset( $_GET['updated'] ) && isset( $_GET['page'] ) && $_GET['page'] == 'publicarweb' ) { + echo '
+

Changes saved successfully

+
'; + } +} + +// Validaciones +add_action( 'current_screen', 'wemcor_redirects' ); +function wemcor_redirects(){ + $screen = get_current_screen(); + if( $screen->id !== 'sites_page_publicarweb-network' ) { + return; + } + + $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; + + if ( ! $id ) { + wp_die( __('Invalid site ID.') ); + } + + $details = get_site( $id ); + if ( ! $details ) { + wp_die( __( 'The requested site does not exist.' ) ); + } + + // if ( ! can_edit_network( $details->site_id ) ) { + // wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); + // } +} + +// Esconder menu en barra lateral (ya se muestra en tabs de site info) +add_action( 'admin_head', 'wemcor_hide_publicar_web' ); +function wemcor_hide_publicar_web() { + + echo ''; +} + +//leemos opción guardada en la base de datos. Si es false se hará visible el site. Si es true se redirigirá a wp-login +add_action( 'template_redirect', 'wemcor_make_private_blog' ); +function wemcor_make_private_blog() { + $id_blog = get_current_blog_id(); + $private_blog = get_blog_option($id_blog, 'wemcor-publicarweb', 0); + + if( !is_user_logged_in() && !$private_blog ) auth_redirect(); + // if( !is_user_logged_in() && !$private_blog ) { + // wp_redirect('https://sso.montseny.digitaldemocratic.net/auth/realms/master/protocol/saml?SAMLRequest=hVLLbtswELz7KwLeJYqKrcKE7cCJ%2BzDg2kbs9tBLwFBrmwBf5VJ18%2FelpOZVICnBy87uDGcHnKAw2vN5E0%2F2Fn42gHFwkc5voy3yrjklTbDcCVTIrTCAPEq%2Bm39d8TIvuA8uOuk0%2BYf2PksgQojK2Z62XEzJZv1xtfm8XN8JEHBZjev7ejQsq0NVVKyQxWgITNSsLD5U4yEbyvG4p36HgElnSpIsGfRqiA0sLUZhY8KLkmXFKCuLPWO8TPfyR09dpGWVFbGjn2L0yClFdLlxNiLYh7xWRxWFrsE4GdKgzC1EKlJYNIDQBqkRGCHQxxRou3qvvv0LXStbK3t8P4%2F7fgj5l%2F1%2Bm203u30vMn%2FM6cZZbAyEHYRfSsK329Wz5bP%2Fn%2BOzz7Q7Kpv7k79qLd4JiWTWPTFpa95lFmapn7X1hL5En%2Bc8Xyfvy8XWaSUfOrw9n1wwIr69IstZh6g6O3SjvLHoQaqDgpo8ycy1dueblGyEKYmhAXJBZ4Pey%2Bs%2FOvsD&RelayState=%2Fwp-login.php&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=rDyFPOMZI04Xx8gBKUZJnm9E5f7ZK1OxXHaITky30js8CvuLZKN05hnmM9s5nROGqX7Hri4MDssiU47%2BF%2FOZHWWL6kngMaQ%2BNZNb9FWsA33r1HpyDUZYZYeGz0rT8aTgv%2BTmexAmtGXa3K3cO7lDDFSkyruFuMdlm2z9bidiKxGJT7BNeEA5D7W%2FXNHvMls0%2Faeq%2BgYIq0HZjlZPpuWcNNL5rGGpQYbU%2F5FYmZ8yy30Aohr2nUkbuif%2BHkyGup1jEBGjktHZamHveydXN18FULc9CsILt0N09tmvFMPa31oBz1%2Fcf0O%2BORJasSygE%2BYwJaBPFF6Pz9btfj6XNFA8Ng%3D%3D'); + // exit; + // } +} diff --git a/docker/wordpress/plugins/mu-plugins/wemcor-patterns.php b/docker/wordpress/plugins/mu-plugins/wemcor-patterns.php new file mode 100644 index 0000000..25561bf --- /dev/null +++ b/docker/wordpress/plugins/mu-plugins/wemcor-patterns.php @@ -0,0 +1,77 @@ + 'Encabezados' + ) + ); +} + +// Registro de patrones +add_action( 'init', 'wemcor_register_block_patterns' ); +function wemcor_register_block_patterns() { + if ( ! class_exists( 'WP_Block_Patterns_Registry' ) ) { + return; + } + + //leemos directorio de templates para cargar todos los patterns + require_once ABSPATH . 'wp-admin/includes/file.php'; + $files = list_files( dirname(__FILE__) . '/templates/', 1); + foreach($files as $file) { + // /home/customer/www/test.wemcor.es/public_html/wp-content/mu-plugins/templates/template-fashion.json + $name = explode("/", $file); + wemcor_register_pattern( end($name) ); + } + +} + +function wemcor_register_pattern( $file ) { + $url = WPMU_PLUGIN_URL . '/templates/' . $file; + $json = file_get_contents($url); + $json_data = json_decode($json, true); + + //rename + $name = str_replace('-', ' ', $file); + $name = str_replace('.json', '', $name); + + register_block_pattern( + 'wem-gutenberg-blocks-patterns/'.$file, + array( + 'title' => ucfirst($name), + 'content' => $json_data['content'], + 'categories' => [ 'wem-templates' ], + ) + ); +} + + diff --git a/docker/wordpress/plugins/mu-plugins/wemcor-roles.php b/docker/wordpress/plugins/mu-plugins/wemcor-roles.php new file mode 100644 index 0000000..1e38f69 --- /dev/null +++ b/docker/wordpress/plugins/mu-plugins/wemcor-roles.php @@ -0,0 +1,145 @@ + true, + 'delete_pages' => true, + 'delete_private_pages' => true, + 'delete_publisehd_pages' => true, + 'edit_others_pages' => true, + 'edit_pages' => true, + 'edit_private_pages' => true, + 'edit_published_pages' => true, + 'publish_pages' => true, + 'read_private_pages' => true, + //posts + 'delete_others_posts' => true, + 'delete_posts' => true, + 'delete_private_posts' => true, + 'delete_publisehd_posts' => true, + 'edit_others_posts' => true, + 'edit_posts' => true, + 'edit_private_posts' => true, + 'edit_published_posts' => true, + 'publish_posts' => true, + 'read_private_posts' => true, + //themes + 'delete_themes' => false, + 'edit_theme_options' => false, + 'edit_themes' => false, + 'install_themes' => false, + 'switch_themes' => false, + 'update_themes' => false, + //plugins + 'activate_plugins' => false, + 'delete_plugins' => false, + 'edit_plugins' => false, + 'install_plugins' => false, + 'update_plugins' => false, + //users + 'add_users' => true, + 'create_users' => false, + 'delete_users' => false, + 'edit_users' => true, + 'list_users' => true, + 'promote_users' => true, + 'remove_users' => false, + //core & others & general + 'customize' => false, + 'edit_dashboard' => false, + 'edit_files' => true, + 'export' => false, + 'import' => false, + 'manage_categories' => true, + 'manage_links' => true, + 'manage_options' => false, + 'moderate_comments' => true, + 'read' => true, + 'unfiltered_html' => true, + 'update_core' => false, + 'upload_files' => true, + ]; + + //capabilities de multisite + if ( is_multisite() ) : + //sites (multisite) + $capabilities['create_sites'] = false; + $capabilities['delete_site'] = false; + $capabilities['delete_sites'] = false; + $capabilities['manage_network'] = true; + $capabilities['manage_network_options'] = true; + $capabilities['manage_network_plugins'] = false; + $capabilities['manage_network_themes'] = false; + $capabilities['manage_network_users'] = true; + $capabilities['manage_sites'] = true; + $capabilities['setup_network'] = true; + $capabilities['upgrade_network'] = false; + endif; + + /* + * Teacher + */ + if ( is_multisite() ) add_role( 'teacher', 'Teacher', $capabilities ); + + //modificamos algunas de las capabilities de los argumentos para crear student + if ( is_multisite() ) $capabilities['manage_network_users'] = false; + if ( is_multisite() ) $capabilities['manage_sites'] = false; + $capabilities['add_users'] = false; + $capabilities['edit_users'] = false; + $capabilities['list_users'] = false; + $capabilities['promote_users'] = false; + $capabilities['moderate_comments'] = false; + + /* + * Student + */ + if ( is_multisite() ) add_role( 'student', 'Student', $capabilities ); +} + +/* + * Eliminar Roles + * + * Eliminar Roles Multisite / WordPress excepto superadmin y los creados Teacher y Student + * + */ +add_action( 'init', 'wemcor_remove_roles', 10 ); +function wemcor_remove_roles() { + if( is_multisite() ) : + //Admin + remove_role( 'admin' ); + //Editor + remove_role( 'editor' ); + //Author + remove_role( 'author' ); + //Contributor + remove_role( 'contributor' ); + //Subscriber + remove_role( 'subscriber' ); + /*anular cuando esté en producción*/ + //Teacher + remove_role( 'teacher' ); + //Student + remove_role( 'student' ); + endif; +} \ No newline at end of file diff --git a/docker/wordpress/wordpress.yml b/docker/wordpress/wordpress.yml index 9a65b85..350be10 100644 --- a/docker/wordpress/wordpress.yml +++ b/docker/wordpress/wordpress.yml @@ -5,7 +5,8 @@ x-volumes: - /etc/localtime:/etc/localtime:ro - ${BUILD_ROOT_PATH}/docker/wordpress/src/config/php.conf.ini:/usr/local/etc/php/conf.d/conf.ini - ${SRC_FOLDER}/wordpress:/var/www/html # Full wordpress project - - ${BUILD_ROOT_PATH}/docker/wordpress/plugins/saml/onelogin-saml-sso:/var/www/html/wp-content/plugins/ + # - ${BUILD_ROOT_PATH}/docker/wordpress/plugins/saml/onelogin-saml-sso:/var/www/html/wp-content/plugins/ + - ${BUILD_ROOT_PATH}/docker/wordpress/plugins:/plugins - ${BUILD_ROOT_PATH}/docker/wordpress/.htaccess:/var/www/html/.htaccess:ro - ${BUILD_ROOT_PATH}/docker/wordpress/multisite.sh:/multisite.sh:ro - ${DATA_FOLDER}/wordpress:/var/www/html/wp-content/uploads