Test Foro de elhacker.net SMF 2.1

Programación => Desarrollo Web => PHP => Mensaje iniciado por: yagami2k2 en 2 Julio 2010, 17:33 PM

Título: Fatal error: Call to undefined function get_option()
Publicado por: yagami2k2 en 2 Julio 2010, 17:33 PM
Hola cómo va? después de mi letargo  ;D vuelvo a mis andanzas pero con un duda.
Instale el WampServer y luego puse una pagina que esta en php, pero, me da un error que es: Fatal error: Call to undefined function get_option() in C:\wamp\www\mainstall.php on line 9

Código (php) [Seleccionar]
<?php

if (version_compare(PHP_VERSION'5.0.0.''<'))
{
die("WP Robot requires php 5 or a greater version to work.");
}

if (!
defined('WP_CONTENT_URL')) 
{
define('WP_CONTENT_URL'get_option('siteurl') . '/wp-content');}


y la linea que me da el error es la última que esta en el code. No se casi nada de php (materia pendiente) y necesito saber si se puede solucionar de alguna forma.

Desde ya gracias.

Título: Re: Fatal error: Call to undefined function get_option()
Publicado por: Shell Root en 2 Julio 2010, 18:07 PM
mmm nunca había visto esa función en PHP, pero después de buscarla en Google, me dice que es una función de WordPress. :http://wpseek.com/get_option/
Título: Re: Fatal error: Call to undefined function get_option()
Publicado por: yagami2k2 en 2 Julio 2010, 18:12 PM
Funciona únicamente con WordPress o se lo podría adaptar para que funcione de otra forma?
Título: Re: Fatal error: Call to undefined function get_option()
Publicado por: Shell Root en 2 Julio 2010, 18:18 PM
Ps no se xD, tendría que ver el source para ver como esta construido. Pero el problema esta en el porque no puedes llamar esa función, si esta dentro del archivo wp-includes/functions.php

Edit:
Código (php) [Seleccionar]
274
275 /**
276 * Retrieve option value based on name of option.
277 *
278 * If the option does not exist or does not have a value, then the return value
279 * will be false. This is useful to check whether you need to install an option
280 * and is commonly used during installation of plugin options and to test
281 * whether upgrading is required.
282 *
283 * If the option was serialized then it will be unserialized when it is returned.
284 *
285 * @since 1.5.0
286 * @package WordPress
287 * @subpackage Option
288 * @uses apply_filters() Calls 'pre_option_$option' before checking the option.
289 *      Any value other than false will "short-circuit" the retrieval of the option
290 *      and return the returned value. You should not try to override special options,
291 *      but you will not be prevented from doing so.
292 * @uses apply_filters() Calls 'option_$option', after checking the option, with
293 *      the option value.
294 *
295 * @param string $option Name of option to retrieve. Expected to not be SQL-escaped.
296 * @return mixed Value set for the option.
297 */
298 function get_option( $option, $default = false ) {
299         global $wpdb;
300
301         // Allow plugins to short-circuit options.
302         $pre = apply_filters( 'pre_option_' . $option, false );
303         if ( false !== $pre )
304                 return $pre;
305
306         $option = trim($option);
307         if ( empty($option) )
308                 return false;
309
310         if ( defined( 'WP_SETUP_CONFIG' ) )
311                 return false;
312
313         if ( ! defined( 'WP_INSTALLING' ) ) {
314                 // prevent non-existent options from triggering multiple queries
315                 $notoptions = wp_cache_get( 'notoptions', 'options' );
316                 if ( isset( $notoptions[$option] ) )
317                         return $default;
318
319                 $alloptions = wp_load_alloptions();
320
321                 if ( isset( $alloptions[$option] ) ) {
322                         $value = $alloptions[$option];
323                 } else {
324                         $value = wp_cache_get( $option, 'options' );
325
326                         if ( false === $value ) {
327                                 $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
328
329                                 // Has to be get_row instead of get_var because of funkiness with 0, false, null values
330                                 if ( is_object( $row ) ) {
331                                         $value = $row->option_value;
332                                         wp_cache_add( $option, $value, 'options' );
333                                 } else { // option does not exist, so we must cache its non-existence
334                                         $notoptions[$option] = true;
335                                         wp_cache_set( 'notoptions', $notoptions, 'options' );
336                                         return $default;
337                                 }
338                         }
339                 }
340         } else {
341                 $suppress = $wpdb->suppress_errors();
342                 $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
343                 $wpdb->suppress_errors( $suppress );
344                 if ( is_object( $row ) )
345                         $value = $row->option_value;
346                 else
347                         return $default;
348         }
349
350         // If home is not set use siteurl.
351         if ( 'home' == $option && '' == $value )
352                 return get_option( 'siteurl' );
353
354         if ( in_array( $option, array('siteurl', 'home', 'category_base', 'tag_base') ) )
355                 $value = untrailingslashit( $value );
356
357         return apply_filters( 'option_' . $option, maybe_unserialize( $value ) );
358 }
Título: Re: Fatal error: Call to undefined function get_option()
Publicado por: yagami2k2 en 2 Julio 2010, 18:25 PM
Quédate tranquilo, el source es largo y son varias páginas que estan enlazadas como módulos. Es un auto posteador, pensé que era para blogger pero como tu dices es para WordPress. Ya lo voy a ver.

Gracias.