There are two errors in your code.
-
"echo'plugins_url( '/image/top.png', __FILE__ )'"
is not executed, it is just a string that happens to look like PHP code.
What you really want is:$arr = array( "top_image"=> plugins_url( '/image/top.png', __FILE__ ) );
-
Do not store default options in the database. Use the second parameter for
get_option( $option, $default );
instead.So whenever you fetch the option, provide the default values as second argument:
$option = get_option( 'scroll_options', array( "top_image"=> plugins_url( '/image/top.png', __FILE__ ) ) );
The reason is that you cannot rely on the stored values anyway. They might be deleted already, so you have to provide the default values always.
Related Posts:
- What’s the preferred method of writing AJAX-enabled plugins?
- How to add a shortcode button to the TinyMCE editor?
- Plugin upgrading: Widget settings
- Create a table in custom plugin on the activating it?
- How would you require and automatically download dependent plugins?
- Is there any record of installed plugins in the database?
- Using require_once in a Plugin?
- How to call “page specific menu items” in template [closed]
- Custom headers for the WordPress plugin directory
- plugin wants to update to wrong plugin
- AJAX Call Via Vanilla JavaScript In WordPress Plugin Development
- Understanding apply_filters
- Editor not displaying dynamically after clicking on the button
- Make the plugin directory recognize new version numbers
- Master menu item for multiple plugins?
- Publish Post After Click On A Link
- Custom url structure for custom template
- Where do I add a new table’s name in wpdb?
- How to create popup same as wordpress popup feature
- How to submit documentation with plugin
- How to customize user search
- Upgrade Private Plugin without Deleting
- Placement of Code in Plugin for hooking `save_post`
- gallery option is not available in media upload box in costum theme option page
- How to make first_name and last_name required fields in user profile?
- Making my plugin translation ready. Poedit not working
- How can plugins have their own pages?
- Can we use a webservice with WordPress?
- WooCommerce get_price returning wrong price when used via ajax
- Open Post Thumbnail in New Child Theme File in WordPress
- Reusable functions and tools (Framework)
- How to create ‘import dummy data’ option in custom wordpress plugin
- Checking instances of scripts in wp_head
- Creating a plugin to sanitize comment and the url field before display only
- Object Oriented Plugin not working
- Creating mySQL procedure with $wpdb
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- Best place for if/else piece of code related to custom plugin?
- How do you assign a UUID to posts/products/comments/reviews?
- How to make a implement queue for scheduling tasks in WordPress?
- What are the specifics of WordPress development I need to know? [closed]
- Insert data from .sql file in wordpress plugin
- Editable form for WordPress plugin options page
- wp-pagenavi getting 404 page not found
- remove add new post, if there is already one post
- Plugin Not Working After Being Uploaded To WordPress Plugin Repository
- Difference and examples of esc_attr__() and esc_attr_e()
- Change the display of Settings API (do_settings_sections)
- WordPress Jquery UI Spinner
- Issue running db create table query from static method
- How can I modify admin bar only if my plugin is loaded
- How to make custom plugin run on demand?
- Using WordPress to build membership Page
- Set WordPress Transient Expiration via Variable Value
- Sanitizing file & directory form input
- Adding custom meta boxes to specified custom post type
- How can I add IP address to my post?
- Override plugin class which has namespace
- How to add/change (woocommerce) product tab icon
- Plugin create pages and use templates
- How to write to a separate PHP file in plugin settings
- Custom CSS not being added by plugin
- How to set the default value as the saved value once a form of widget is saved?
- WordPress Feed Creator Name Tag Full Name Instead Of First Name
- WordPress plugin with its own “site”/theme
- How to add custom function to pluggable.php
- How to get Recent Post From Each Category with Thumbnail?
- Security of a WordPress Plugin
- Remove Zero Money From Previews Order woocommerce
- How use wp_insert_post and add og:custom tags?
- Access remote SFTP server via WordPress login?
- Shortcode do not return the right data in post
- How to change “Read More” text?
- How to use wp_editor and save its data in wp_posts table
- My WordPress activation hook isn’t working
- Performance considerations – postmeta table versus new table for custom posts with foreign keys?
- Securing a plugin pop-up window
- Avoid WordPress header bar when form submission using admin_post in the frontend
- Set “Open in New tab” as default option
- Generate and send ICS file through WordPress
- WordPress ajax error 400 bad request for sending data to remote site [duplicate]
- Field salespeople task management
- Echo custom admin field into a is_single()
- WordPress Boilerplate Plugin doesn’t see callback functions for add_settings_field and add_settings_section
- Hide ‘add to cart’ button for some products [duplicate]
- Exclude specifed files from plugin editor
- Add Flatr button to Sharing option
- Change localization only for plugin
- How to get author developer link on plugin page
- wp_schedule_event need to deactivate plugin changing recurrance
- Create New Admin Menu Section – Like how custom post type works, in a way
- Customize Multi-Column Tag Map to fetch specific post-type
- Combining JS files to one script
- Upload Image to desired directory through plugin
- Jquery post responses 500 error after some time and lastly an 503 error
- How can I delete the options from DB when the plugin is deleted?
- Create Custom Coupon Type
- Is it possible to create post in wordpress using postman?
- wp_enqueue_script doesn’t load JS in plugin
- AI Code For OpenAI