Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is what's causing you problems:</p> <pre><code>$this-&gt;value = unserialize(get_option($keyword)); </code></pre> <p>As some others have previously pointed out, you could update your original post with the actual declarations of the <code>get_option()</code> function and the class that wraps the <code>get_alt_desc(), get_img_url(), get_web_url()</code> methods.</p> <p>It can be assumed that the <code>get_option()</code> function returns a serialised object which implements the following <strong>public</strong> methods:</p> <pre><code>public function get_alt_desc() { /* custom code */ } public function get_img_url() { /* custom code */ } public function get_web_url() { /* custom code */ } </code></pre> <p>By serialising and unserialising your object you lose access to all of the above methods. To avoid that, you need to modify the <code>get_option()</code> function to return the actual object instead of a serialized representation of it.</p> <p>Assuming there is a <code>Value</code> class which represents your object:</p> <pre><code>class Value { protected $alt_desc; protected $img_url; protected $web_url; public function __construct($keyword) { $this-&gt;alt_desc = $keyword[0]; // some string build around $keyword $this-&gt;img_url = $keyword[1]; // some string build around $keyword $this-&gt;web_url = $keyword[2]; // some string build around $keyword } public function get_alt_desc() { return $this-&gt;alt_desc; } public function get_img_url() { return $this-&gt;img_url; } public function get_web_url() { return $this-&gt;web_url; } } </code></pre> <p>Then you could modify your <code>get_option()</code> function to simply return an object:</p> <pre><code>function get_option($keyword) { /* * The code below is just an example * This function must return an object */ return new Value($keyword); } </code></pre> <p>Your <code>Padd_Input_Advertisement</code> constructor should be updated as following:</p> <pre><code>function __construct($keyword,$name,$description='') { $this-&gt;keyword = $keyword; // removed the unserialize call as it's not necessary anymore $this-&gt;value = get_option($keyword); $this-&gt;name = $name; $this-&gt;description = $description; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload