zurück zur Startseite
  


Zurück XHTMLforum > Webentwicklung (außer XHTML und CSS) > Serveradministration und serverseitige Scripte
Seite neu laden wp plugin css & js einfügen

Antwort
 
LinkBack Themen-Optionen Ansicht
  #1 (permalink)  
Alt 09.03.2016, 13:57
Erfahrener Benutzer
XHTMLforum-Mitglied
Thread-Ersteller
 
Registriert seit: 12.11.2010
Ort: Bad Langensalza
Beiträge: 733
gabischatz ist in Verruf geraten
Standard wp plugin css & js einfügen

Hi, ich habe das Problem, dass ich in ein Plugin nicht wie gewohnt eine Script oder Style-Datei eingebunden bekomme.
Ich möchte in den Benutzer Einstellungen ein paar Anpassungen vornehmen.

Das sind nun mein Versuch auf der /wordpress/wp-admin/user-edit.php Seite, dies einzubinden.
PHP-Code:
<?php /* - Codierung: UTF-8 - äöüß */
defined('ABSPATH') || exit(); #Direktzugriff auf diese Datei verhindern
/**
 * Plugin Name: Anpassung, 09.03.2016 09:00
 * Description: Theme unabhängige Anpassungen:  Mehrere Rollen pro Benutzer
 * License: GPL2
**/


/**
 * Class sp_more_rolls_per_user
 * @author    Lutz Müller
 * @version 09.03.2016 09:00
**/
if ( ! class_exists('sp_more_rolls_per_user') )
{
    class 
sp_more_rolls_per_user
    
{
        public function 
__construct()
        {
            
$this->adminlink         admin_url('/''admin');
            
$this->lugmlink            'http://lugm.de/sp_more_rolls_per_user_plugin/';
            
$this->slug                'rolls';
            
$this->file                __FILE__ ;
            
$this->dir                dirname__FILE__ );
            
$this->base                plugin_basename__FILE__ );
            
$this->folder            plugin_dir_path__FILE__ );
            
$this->domain            'http://lspz.de';

            
register_activation_hook   __FILE__, array ( &$this'activate' ) );    // Aktivierung Plugin
                /** Die register_activation_hook führt ein Funktion aus, wenn das Plugin aktiviert wird . **/
            
register_deactivation_hook __FILE__, array ( &$this'deactivate' ) );     // Deaktivierung Plugin
                /** Die register_deactivation_hook führt ein Funktion aus, wenn das Plugin deaktiviert wird . **/
            
register_uninstall_hook       __FILE__, array ( &$this'uninstall' ) );    // Löschen des Plugin
                /** Die register_uninstall_hook führt ein Funktion aus, wenn das Plugin gelöscht wird . **/
        
}# End of __construct
############################################################################################################
        /**
         * Name:      activate
         * Zweck:   Aktivierung des Plugin. Hier setzen wir unsere Hooks.
         * @param   void
        **/
        
public function activate() {
            
// adds links to plugin list page
            
add_filter'plugin_row_meta',                 array( &$this'sp_filter_plugin_links' ), 10);
            
#add_action( 'admin_enqueue_scripts',         array( $this, 'sp_admin_enqueue_scripts'), 10 );
            
add_action'edit_user_profile',             array( &$this'sp_add_multiple_roles_ui'), );
            
add_action'edit_user_profile_update',     array( &$this'sp_save_multiple_user_roles' ));
            
// Script für das Backend-header registrieren
            
add_action'admin_footer',                 array( &$this'sp_save_multiple_user_roles_AddScript' ) );
            
// Styles zum Backend hinzufügen
            
add_action'show_user_profile',             array( &$this'sp_add_multiple_roles_AddStyle' ) );
            
add_action'edit_user_profile',             array( &$this'sp_add_multiple_roles_AddStyle' ) );
            
add_action'admin_print_styles',             array( &$this'sp_add_multiple_roles_AddStyle' ) );
            
add_filter'manage_users_columns',         array( &$this'sp_add_roles_column' ) );
            
add_filter'manage_users_custom_column',     array( &$this'sp_display_user_roles'10) );
            
// Enqueues the script and the styles
            
add_action'plugins_loaded',                 array( &$this'custom_dashboard_admin_init') );
            
add_action'admin_print_scripts-profile.php',      array( &$this'custom_dashboard_admin_init') );
            
add_action'admin_print_scripts-user-edit.php', array( &$this'custom_dashboard_admin_init') );
add_action'admin_print_scripts-profile.php', array( &$this,  'custom_profile_style' ));
add_action'admin_print_scripts-user-edit.php', array( &$this,  'custom_profile_style' ));
add_action'admin_print_scripts-settings_page_user-edit.php', array( &$this,  'custom_profile_style' ));
add_action('admin_init', array( &$this'my_cool_options'));
add_action('admin_print_scripts-profile.php', array( &$this,  'my_cool_styles'));

        } 
# End of activate
############################################################################################################

function my_cool_options() {
        
wp_register_script'mycoolscript'getContentURL() . '/js.js' );
        
wp_register_style'mycoolstyle'getContentURL() . '/css.css' );
    }

function 
my_cool_styles() {
        
wp_enqueue_script'mycoolscript' );
        
wp_enqueue_style'mycoolstyle' );
    }

function 
getContentURL() {
        
$mupluginsurl WP_CONTENT_URL."/mu-plugins";
        return (
$_SERVER['HTTPS'] != "on") ? $mupluginsurl str_replace("http""https"$mupluginsurl);
    }
function 
custom_profile_style() {
    
wp_register_style'custom_profile_css'get_stylesheet_directory_uri() . '/css/css.css' );
    
wp_enqueue_style'custom_profile_css' );
    
wp_register_script'custom_profile_js'get_stylesheet_directory_uri() . '/js/js.js' );
    
wp_enqueue_script'custom_profile_js' );
}
        
/**
         * Name:    custom_dashboard_admin_init
         * Zweck:   Einfügen in das Admin / Dashboard
         * @param   void
        **/
        
public function custom_dashboard_admin_init()
        {
            
// Lädt die übersetzten Plugin-Strings.
            
load_plugin_textdomain'sp_more_rolls_per_user'false$this->base.'/languages/' );

            
// create array of all scripts
            
$scripts = array( 'custom-dashboard-script'  => '/js/js.js' );

            foreach(
$scripts as $key=>$sc)
            {
               
wp_register_script$key$this->base.$sc, array('jquery') );
               
# Admin-Skrips in die Warteschlange einreihen
               
wp_enqueue_script$key );
            }

            
// create array of all styles
            
$styles = array( 'custom-dashboard-styles' => '/css/css.css' );

            foreach(
$styles as $key=>$st)
            {
               
wp_register_styles$key$this->base.$st );
               
# Admin-Styles in die Warteschlange einreihen
               
wp_enqueue_script$key );
            }
        }
############################################################################################################

        /**
         * Name:      deactivate
         * Zweck:   Deaktivierung des Plugin. Hier räumen wir wieder auf, wenn das Plugin deaktiviert wird.
         * @param   void
        **/
        
public function deactivate(){
            
remove_action'plugins_loaded',             array( &$this'sp_plugin_init' ) );
            
// adds links to plugin list page
            
remove_action'plugin_row_meta',             array( &$this'sp_filter_plugin_links' ), 10);
            
// remove jQuery
            #remove_action( 'admin_enqueue_scripts',     array( &$this, 'sp_admin_enqueue_scripts'), 10 );
            
remove_action'edit_user_profile',         array( &$this'sp_add_multiple_roles_ui'), );
            
remove_action'edit_user_profile_update',     array( &$this'sp_save_multiple_user_roles' ));
            
// Styles vom Backend entfernen
            
remove_action'show_user_profile',         array( &$this'sp_add_multiple_roles_AddStyle' ) );
            
remove_action'edit_user_profile',         array( &$this'sp_add_multiple_roles_AddStyle' ) );
            
remove_action'admin_print_styles',         array( &$this'sp_add_multiple_roles_AddStyle' ) );
            
// Script vom Backend entfernen
            
remove_action'admin_footer',                 array( &$this'sp_save_multiple_user_roles_AddScript' ) );
            
// Script vom Backend-footer entfernen
        
# End of deactivate
############################################################################################################
    
}
}
Grüße
Nachtrag: Ich habe vergessen die Klasse zu Indizierenen

Geändert von gabischatz (09.03.2016 um 18:11 Uhr)
Mit Zitat antworten
Sponsored Links
Antwort

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus


Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
Ein Bild mit CSS einfügen? pstein CSS 5 25.09.2013 20:04
CSS Sprite in HTML einfügen enigma2k CSS 3 29.10.2012 12:39
CSS von Plugin beisst! expand CSS 0 28.09.2012 18:44
<object class id=..... in css einfügen??? INTERAKT!V CSS 3 04.06.2007 12:44
Mozilla ignoriert externes css DarkWanderer CSS 9 22.09.2005 12:39


Alle Zeitangaben in WEZ +2. Es ist jetzt 17:52 Uhr.