Foro de elhacker.net

Programación => 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
  1. <?php
  2.  
  3. if (version_compare(PHP_VERSION, '5.0.0.', '<'))
  4. {
  5. die("WP Robot requires php 5 or a greater version to work.");
  6. }
  7.  
  8. if (!defined('WP_CONTENT_URL'))
  9. {define('WP_CONTENT_URL', get_option('siteurl') . '/wp-content');}
  10.  

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
  1. 274
  2. 275 /**
  3. 276 * Retrieve option value based on name of option.
  4. 277 *
  5. 278 * If the option does not exist or does not have a value, then the return value
  6. 279 * will be false. This is useful to check whether you need to install an option
  7. 280 * and is commonly used during installation of plugin options and to test
  8. 281 * whether upgrading is required.
  9. 282 *
  10. 283 * If the option was serialized then it will be unserialized when it is returned.
  11. 284 *
  12. 285 * @since 1.5.0
  13. 286 * @package WordPress
  14. 287 * @subpackage Option
  15. 288 * @uses apply_filters() Calls 'pre_option_$option' before checking the option.
  16. 289 *      Any value other than false will "short-circuit" the retrieval of the option
  17. 290 *      and return the returned value. You should not try to override special options,
  18. 291 *      but you will not be prevented from doing so.
  19. 292 * @uses apply_filters() Calls 'option_$option', after checking the option, with
  20. 293 *      the option value.
  21. 294 *
  22. 295 * @param string $option Name of option to retrieve. Expected to not be SQL-escaped.
  23. 296 * @return mixed Value set for the option.
  24. 297 */
  25. 298 function get_option( $option, $default = false ) {
  26. 299        global $wpdb;
  27. 300
  28. 301        // Allow plugins to short-circuit options.
  29. 302        $pre = apply_filters( 'pre_option_' . $option, false );
  30. 303        if ( false !== $pre )
  31. 304                return $pre;
  32. 305
  33. 306        $option = trim($option);
  34. 307        if ( empty($option) )
  35. 308                return false;
  36. 309
  37. 310        if ( defined( 'WP_SETUP_CONFIG' ) )
  38. 311                return false;
  39. 312
  40. 313        if ( ! defined( 'WP_INSTALLING' ) ) {
  41. 314                // prevent non-existent options from triggering multiple queries
  42. 315                $notoptions = wp_cache_get( 'notoptions', 'options' );
  43. 316                if ( isset( $notoptions[$option] ) )
  44. 317                        return $default;
  45. 318
  46. 319                $alloptions = wp_load_alloptions();
  47. 320
  48. 321                if ( isset( $alloptions[$option] ) ) {
  49. 322                        $value = $alloptions[$option];
  50. 323                } else {
  51. 324                        $value = wp_cache_get( $option, 'options' );
  52. 325
  53. 326                        if ( false === $value ) {
  54. 327                                $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
  55. 328
  56. 329                                // Has to be get_row instead of get_var because of funkiness with 0, false, null values
  57. 330                                if ( is_object( $row ) ) {
  58. 331                                        $value = $row->option_value;
  59. 332                                        wp_cache_add( $option, $value, 'options' );
  60. 333                                } else { // option does not exist, so we must cache its non-existence
  61. 334                                        $notoptions[$option] = true;
  62. 335                                        wp_cache_set( 'notoptions', $notoptions, 'options' );
  63. 336                                        return $default;
  64. 337                                }
  65. 338                        }
  66. 339                }
  67. 340        } else {
  68. 341                $suppress = $wpdb->suppress_errors();
  69. 342                $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
  70. 343                $wpdb->suppress_errors( $suppress );
  71. 344                if ( is_object( $row ) )
  72. 345                        $value = $row->option_value;
  73. 346                else
  74. 347                        return $default;
  75. 348        }
  76. 349
  77. 350        // If home is not set use siteurl.
  78. 351        if ( 'home' == $option && '' == $value )
  79. 352                return get_option( 'siteurl' );
  80. 353
  81. 354        if ( in_array( $option, array('siteurl', 'home', 'category_base', 'tag_base') ) )
  82. 355                $value = untrailingslashit( $value );
  83. 356
  84. 357        return apply_filters( 'option_' . $option, maybe_unserialize( $value ) );
  85. 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.