{"id":4742971,"date":"2014-03-25T22:15:01","date_gmt":"2014-03-25T22:15:01","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/function-from-functionphp\/"},"modified":"2016-08-21T18:40:11","modified_gmt":"2016-08-21T18:40:11","slug":"function-from-functionphp","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/function-from-functionphp\/","title":{"rendered":"Function from function.php"},"content":{"rendered":"<p>Hi !<\/p>\n<p>I try to call into a widget a function from function.php file. I call the function in a widget into the sidebar with this:<\/p>\n<p><code>&lt;?php add_login_logout_link($items, $args); ?&gt;<\/code><\/p>\n<p>My function from function .php is:<\/p>\n<pre><code>&lt;?php\nfunction add_login_logout_link($items, $args)\n{\n  if(is_user_logged_in())\n  {\n    $newitems = $$items;\n    $newitems .= &#039;\n                  &lt;li&gt;&lt;a class=&quot;button wc-forward&quot; title=&quot;mon compte&quot; href=&quot;\/mon-compte\/&quot;&gt;Mon compte&lt;\/a&gt;&lt;\/li&gt;\n                  &lt;li&gt;&lt;a class=&quot;button wc-forward&quot; title=&quot;se d\u00e9connecter&quot; href=&quot;&#039;. wp_logout_url(&#039;index.php&#039;) .&#039;&quot;&gt;Se d\u00e9connecter&lt;\/a&gt;&lt;\/li&gt;&#039;;\n  }\n  else\n  {\n    $newitems = $items;\n    $newitems .= &#039;&lt;li&gt;&lt;a class=&quot;button wc-forward&quot; title=&quot;Login&quot; href=&quot;&#039;. wp_login_url(&#039;\/catalogue-investissement\/&#039;) .&#039;&quot;&gt;Se connecter&lt;\/a&gt;&lt;\/li&gt;&#039;;\n  }\n\n  return $newitems;\n}\n?&gt;<\/code><\/pre>\n<p>Nothing is display this that. I try to use $GLOBALS[&#8216;variablex&#8217;] but it doesn&#8217;t work.<\/p>\n<p>Thanks for your help. I keep trying to find !<\/p>\n<p>https:\/\/wordpress.org\/plugins\/php-code-widget\/<\/p>\n","protected":false},"template":"","class_list":["post-4742971","topic","type-topic","status-closed","hentry","topic-tag-function-php","topic-tag-php","topic-tag-sidebar","topic-tag-widget"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/4742971","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/4742971\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=4742971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}