php script van een wordpress plugin

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Robert Segal

Robert Segal

11/01/2014 03:51:19
Quote Anchor link
Beste experts,

Sinds kort verdiep ik mij in websites en bouw ik mijn eigen website via Wordpress. Ik heb een theme met verschillende plugins geïnstalleerd. 1 van die plugins is een programma als een veiling etc.

Nu zit ik met een probleem. Als ik een nieuwe veiling aanmaak dan word er een standaard sjabloon gebruikt die niet mooi is. Ik heb gekeken in de files van de plugin en daar is er een php bestand met het gebruik van templates.

nu vraag ik jullie advies wat ik in dit php script moet veranderen om met een standaard template te werken voor elke veiling. dus met elke nieuwe deal/veiling moet hetzelfde template gebruikt worden

hieronder staat het php script

elke advies is welkom!

bijvoorbaat dank,

Robert
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php

// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;

/**
 * Templates Functions
 *
 * Handles to manage templates of plugin
 *
 * @package Social Deals Engine
 * @since 1.0.0
 *
 */


/**
 * Returns the path to the Deals templates directory
 *
 * @package Social Deals Engine
 * @since 1.0.0
 */

function wps_deals_get_templates_dir() {
    
    return apply_filters( 'wps_deals_template_dir', WPS_DEALS_DIR . '/includes/templates/' );
    
}

/**
 * Get template part.
 *
 * @package Social Deals Engine
 * @since 1.0.0
 */

function wps_deals_get_template_part( $slug, $name='' ) {
    
    $template = '';

    // Look in yourtheme/slug-name.php and yourtheme/deals-engine/slug-name.php
    if ( $name )
        $template = locate_template( array ( $slug.'-'.$name.'.php', wps_deals_get_templates_dir().$slug.'-'.$name.'.php' ) );

    // Get default slug-name.php
    if ( !$template && $name && file_exists( wps_deals_get_templates_dir().$slug.'-'.$name.'.php' ) )
        $template = wps_deals_get_templates_dir().$slug.'-'.$name.'.php';

    // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/deals-engine/slug.php
    if ( !$template )
        $template = locate_template( array ( $slug.'.php', wps_deals_get_templates_dir().$slug.'.php' ) );

    if ( $template )
        load_template( $template, false );
}



/**
 * Locate a template and return the path for inclusion.
 *
 * This is the load order:
 *
 *        yourtheme        /    $template_path    /    $template_name
 *        yourtheme        /    $template_name
 *        $default_path    /    $template_name
 *
 * @package Social Deals Engine
 * @since 1.0.0
 *
 */

function wps_deals_locate_template( $template_name, $template_path = '', $default_path = '' ) {
    
    if ( ! $template_path ) $template_path = WPS_DEALS_BASENAME . '/';//wps_deals_get_templates_dir();
    if ( ! $default_path ) $default_path = wps_deals_get_templates_dir();
    
    // Look within passed path within the theme - this is priority
    
    $template = locate_template(
        array(
            trailingslashit( $template_path ) . $template_name,
            $template_name
        )
    );

    
    // Get default template
    if ( ! $template )
        $template = $default_path . $template_name;

    // Return what we found
    return apply_filters('wps_deals_locate_template', $template, $template_name, $template_path);
}


/**
 * Get other templates (e.g. deals attributes) passing attributes and including the file.
 *
 * @package Social Deals Engine
 * @since 1.0.0
 *
 */


function wps_deals_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
    
    if ( $args && is_array($args) )
        extract( $args );

    $located = wps_deals_locate_template( $template_name, $template_path, $default_path );
    
    do_action( 'wps_deals_before_template_part', $template_name, $template_path, $located, $args );

    include( $located );

    do_action( 'wps_deals_after_template_part', $template_name, $template_path, $located, $args );
}

?>



- Aar -:
Ik heb het script even stevig ingesnoeid. Houd het in het vervolg bij relevante code i.p.v. een lap van honderden regels aan code.
Gewijzigd op 24/06/2014 18:52:21 door - Ariën -
 
PHP hulp

PHP hulp

24/04/2024 22:42:05
 
Koen Vlaswinkel

Koen Vlaswinkel

11/01/2014 07:59:24
Quote Anchor link
Plaats aub alleen relevante code, niemand hier heeft zin om 2000+ regels te gaan doorzoeken.
 
Wilko van der Ploeg

Wilko van der Ploeg

24/06/2014 16:02:00
Quote Anchor link
Even los van het feit, dat niemand inderdaad 2000 regels of meer gaat doorwroeten, dit script deel is van een complete plugin en ook verwijst naar andere script-bestanden binnen die plugin en het feit dat jij eigenlijk iemand vraagt om zomaar enkele uren tijd te steken in iets voor jouw plezier, moet je dit helemaal niet aan WILLEN passen. WordPress is een systeem waar het updaten van plugins en thema's heel eenvoudig door gebruikers is uit te voeren. En dat is goed. Maar zodra jij in een plugin gaat 'hacken', kan hij niet meer geupdate worden. Wat een veiligheidsrisico is. Wat ervoor zorgt dat allerlei foutherstel niet doorgevoerd wordt, wat ervoor zorgt, dat je allerlei nieuwe leuke uitbreidingen in de functionaliteit mis gaat lopen.

Wat je beter kunt doen is contact opnemen met de maker van de plugin en een 'feature request' indienen... de mogelijkheid om eigen templates de definieren.

Vriendelijke Groet
Wilko van der Ploeg
 
Gerhard l

gerhard l

24/06/2014 16:08:15
Quote Anchor link
IK heb ook geen zin om alles door te lezen, maar met een beetje mazzel werkt dit, vervang de huidige functie door deze:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
function wps_deals_locate_template( $template_name, $template_path = '', $default_path = '' ) {  
    $template = $default_path . $template_name;
    return apply_filters('wps_deals_locate_template', $template, $template_name, $template_path);
}
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.